mirror of https://gitee.com/stylefeng/roses
【8.0】【dict】单独抽出行政区域模块
parent
555f70c3af
commit
dc0a1c991c
|
@ -1,97 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="cn.stylefeng.roses.kernel.dict.modular.mapper.AreaMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="cn.stylefeng.roses.kernel.dict.modular.entity.Area">
|
||||
<id column="area_id" property="areaId" />
|
||||
<result column="area_code" property="areaCode" />
|
||||
<result column="area_name" property="areaName" />
|
||||
<result column="parent_id" property="parentId" />
|
||||
<result column="area_level" property="areaLevel" />
|
||||
<result column="area_sort" property="areaSort" />
|
||||
<result column="del_flag" property="delFlag" />
|
||||
<result column="area_pids" property="areaPids" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="create_user" property="createUser" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="update_user" property="updateUser" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="customResultMap" type="cn.stylefeng.roses.kernel.dict.modular.pojo.AreaVo" extends="BaseResultMap">
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
area_id,area_code,area_name,parent_id,area_level,area_sort,del_flag,area_pids,create_time,create_user,update_time,update_user
|
||||
</sql>
|
||||
|
||||
|
||||
|
||||
<select id="selectAll" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM
|
||||
sys_area
|
||||
</select>
|
||||
|
||||
<select id="customFindList" resultMap="customResultMap">
|
||||
SELECT
|
||||
tbl.area_id,
|
||||
tbl.area_code,
|
||||
tbl.area_name,
|
||||
tbl.parent_id,
|
||||
tbl.area_level,
|
||||
tbl.area_sort,
|
||||
tbl.del_flag,
|
||||
tbl.area_pids,
|
||||
tbl.create_time,
|
||||
tbl.create_user,
|
||||
tbl.update_time,
|
||||
tbl.update_user
|
||||
|
||||
FROM
|
||||
sys_area tbl
|
||||
WHERE tbl.del_flag = 'N'
|
||||
<if test="param.areaId != null ">
|
||||
and tbl.area_id = #{param.areaId}
|
||||
</if>
|
||||
<if test="param.areaCode != null and param.areaCode != ''">
|
||||
and tbl.area_code like concat('%',#{param.areaCode},'%')
|
||||
</if>
|
||||
<if test="param.areaName != null and param.areaName != ''">
|
||||
and tbl.area_name like concat('%',#{param.areaName},'%')
|
||||
</if>
|
||||
<if test="param.parentId != null and param.parentId != ''">
|
||||
and tbl.parent_id like concat('%',#{param.parentId},'%')
|
||||
</if>
|
||||
<if test="param.areaLevel != null ">
|
||||
and tbl.area_level = #{param.areaLevel}
|
||||
</if>
|
||||
<if test="param.areaSort != null ">
|
||||
and tbl.area_sort = #{param.areaSort}
|
||||
</if>
|
||||
<if test="param.delFlag != null and param.delFlag != ''">
|
||||
and tbl.del_flag like concat('%',#{param.delFlag},'%')
|
||||
</if>
|
||||
<if test="param.areaPids != null and param.areaPids != ''">
|
||||
and tbl.area_pids like concat('%',#{param.areaPids},'%')
|
||||
</if>
|
||||
<if test="param.createTime != null ">
|
||||
and tbl.create_time = #{param.createTime}
|
||||
</if>
|
||||
<if test="param.createUser != null ">
|
||||
and tbl.create_user = #{param.createUser}
|
||||
</if>
|
||||
<if test="param.updateTime != null ">
|
||||
and tbl.update_time = #{param.updateTime}
|
||||
</if>
|
||||
<if test="param.updateUser != null ">
|
||||
and tbl.update_user = #{param.updateUser}
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
package cn.stylefeng.roses.kernel.dict.modular.pojo;
|
||||
|
||||
|
||||
import cn.stylefeng.roses.kernel.dict.modular.entity.Area;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 【系统基础】-【行政区域表】实例类
|
||||
*
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
@Data
|
||||
public class AreaVo extends Area {
|
||||
|
||||
|
||||
}
|
|
@ -1,126 +0,0 @@
|
|||
package cn.stylefeng.roses.kernel.dict.modular.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.rule.constants.TreeConstants;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.dict.modular.entity.Area;
|
||||
import cn.stylefeng.roses.kernel.dict.modular.enums.AreaExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.dict.modular.mapper.AreaMapper;
|
||||
import cn.stylefeng.roses.kernel.dict.modular.pojo.AreaVo;
|
||||
import cn.stylefeng.roses.kernel.dict.modular.pojo.request.AreaRequest;
|
||||
import cn.stylefeng.roses.kernel.dict.modular.service.AreaService;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 【系统基础】-【行政区域表】业务实现层
|
||||
*
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
@Service
|
||||
public class AreaServiceImpl extends ServiceImpl<AreaMapper, Area> implements AreaService {
|
||||
|
||||
@Override
|
||||
public void add(AreaRequest areaRequest) {
|
||||
Area area = new Area();
|
||||
BeanUtil.copyProperties(areaRequest, area);
|
||||
this.save(area);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void del(AreaRequest areaRequest) {
|
||||
Area area = this.queryArea(areaRequest);
|
||||
this.removeById(area.getAreaId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(AreaRequest areaRequest) {
|
||||
Area area = this.queryArea(areaRequest);
|
||||
BeanUtil.copyProperties(areaRequest, area);
|
||||
this.updateById(area);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Area detail(AreaRequest areaRequest) {
|
||||
return this.queryArea(areaRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<AreaVo> findPage(AreaRequest areaRequest) {
|
||||
Page<AreaVo> page = PageFactory.defaultPage();
|
||||
List<AreaVo> list = baseMapper.customFindList(page, areaRequest);
|
||||
PageResult<AreaVo> pageResult = PageResultFactory.createPageResult(page.setRecords(list));
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Area> findList(AreaRequest areaRequest) {
|
||||
|
||||
LambdaQueryWrapper<Area> queryWrapper = new LambdaQueryWrapper<>();
|
||||
String parentId = areaRequest.getParentId();
|
||||
if(ObjectUtil.isEmpty(parentId)) {
|
||||
parentId=TreeConstants.DEFAULT_PARENT_ID.toString();
|
||||
}
|
||||
queryWrapper.select(Area::getAreaId,Area::getAreaName,Area::getAreaCode);
|
||||
queryWrapper.eq(Area::getParentId, parentId);
|
||||
queryWrapper.orderByAsc(Area::getAreaSort);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息
|
||||
*
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
private Area queryArea(AreaRequest areaRequest) {
|
||||
Area area = this.getById(areaRequest.getAreaId());
|
||||
if (ObjectUtil.isEmpty(area)) {
|
||||
throw new ServiceException(AreaExceptionEnum.AREA_NOT_EXISTED);
|
||||
}
|
||||
return area;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建查询wrapper
|
||||
*
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
private LambdaQueryWrapper<Area> createWrapper(AreaRequest areaRequest) {
|
||||
LambdaQueryWrapper<Area> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
Long areaId = areaRequest.getAreaId();
|
||||
String areaCode = areaRequest.getAreaCode();
|
||||
String areaName = areaRequest.getAreaName();
|
||||
String parentId = areaRequest.getParentId();
|
||||
Integer areaLevel = areaRequest.getAreaLevel();
|
||||
BigDecimal areaSort = areaRequest.getAreaSort();
|
||||
String delFlag = areaRequest.getDelFlag();
|
||||
String areaPids = areaRequest.getAreaPids();
|
||||
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(areaId), Area::getAreaId, areaId);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(areaCode), Area::getAreaCode, areaCode);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(areaName), Area::getAreaName, areaName);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(parentId), Area::getParentId, parentId);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(areaLevel), Area::getAreaLevel, areaLevel);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(areaSort), Area::getAreaSort, areaSort);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(delFlag), Area::getDelFlag, delFlag);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(areaPids), Area::getAreaPids, areaPids);
|
||||
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
城市-省市县联动的字典
|
|
@ -0,0 +1,67 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-s-dict</artifactId>
|
||||
<version>8.0.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>dict-city-business</artifactId>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!--字典模块api-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>dict-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--缓存的依赖-->
|
||||
<!--字典缓存的使用-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>cache-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--资源api模块-->
|
||||
<!--用在资源控制器,资源扫描上-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>scanner-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--参数校验模块-->
|
||||
<!--用在控制器,参数校验-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>validator-api-table-unique</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--数据库sdk-->
|
||||
<!--数据库dao框架-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>db-sdk-mp</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--web模块-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,11 +1,10 @@
|
|||
package cn.stylefeng.roses.kernel.dict.modular.controller;
|
||||
package cn.stylefeng.roses.kernel.city.modular.controller;
|
||||
|
||||
import cn.stylefeng.roses.kernel.city.modular.entity.Area;
|
||||
import cn.stylefeng.roses.kernel.city.modular.pojo.AreaVo;
|
||||
import cn.stylefeng.roses.kernel.city.modular.pojo.request.AreaRequest;
|
||||
import cn.stylefeng.roses.kernel.city.modular.service.AreaService;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.dict.modular.entity.Area;
|
||||
import cn.stylefeng.roses.kernel.dict.modular.pojo.AreaVo;
|
||||
import cn.stylefeng.roses.kernel.dict.modular.pojo.request.AreaRequest;
|
||||
import cn.stylefeng.roses.kernel.dict.modular.service.AreaService;
|
||||
import cn.stylefeng.roses.kernel.rule.enums.ResBizTypeEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
||||
|
@ -19,13 +18,13 @@ import javax.annotation.Resource;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 【系统基础】-【行政区域表】控制器
|
||||
* 行政区域控制器
|
||||
*
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
@RestController
|
||||
@ApiResource(name = "行政区域", resBizType = ResBizTypeEnum.SYSTEM)
|
||||
@ApiResource(name = "行政区域")
|
||||
public class AreaController {
|
||||
|
||||
@Resource
|
|
@ -1,4 +1,4 @@
|
|||
package cn.stylefeng.roses.kernel.dict.modular.entity;
|
||||
package cn.stylefeng.roses.kernel.city.modular.entity;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
|
@ -9,11 +9,10 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 【系统基础】-【行政区域表】实例类
|
||||
* 行政区域实例类
|
||||
*
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
|
@ -1,11 +1,11 @@
|
|||
package cn.stylefeng.roses.kernel.dict.modular.enums;
|
||||
package cn.stylefeng.roses.kernel.city.modular.enums;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 【系统基础】-【行政区域表】异常相关枚举
|
||||
* 行政区域异常相关枚举
|
||||
*
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
|
@ -16,7 +16,7 @@ public enum AreaExceptionEnum implements AbstractExceptionEnum {
|
|||
/**
|
||||
* 查询结果不存在
|
||||
*/
|
||||
AREA_NOT_EXISTED(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10001", "查询结果不存在");
|
||||
AREA_NOT_EXISTED(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10001", "查询结果不存在");
|
||||
|
||||
/**
|
||||
* 错误编码
|
|
@ -1,20 +1,22 @@
|
|||
package cn.stylefeng.roses.kernel.dict.modular.mapper;
|
||||
package cn.stylefeng.roses.kernel.city.modular.mapper;
|
||||
|
||||
import cn.stylefeng.roses.kernel.city.modular.entity.Area;
|
||||
import cn.stylefeng.roses.kernel.city.modular.pojo.AreaVo;
|
||||
import cn.stylefeng.roses.kernel.city.modular.pojo.request.AreaRequest;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import cn.stylefeng.roses.kernel.dict.modular.entity.Area;
|
||||
import cn.stylefeng.roses.kernel.dict.modular.pojo.AreaVo;
|
||||
import cn.stylefeng.roses.kernel.dict.modular.pojo.request.AreaRequest;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 【系统基础】-【行政区域表】 Mapper 接口
|
||||
* 行政区域 Mapper 接口
|
||||
*
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
public interface AreaMapper extends BaseMapper<Area> {
|
||||
|
||||
List<AreaVo> customFindList(@Param("page") Page page, @Param("param")AreaRequest request);
|
||||
List<AreaVo> customFindList(@Param("page") Page page, @Param("param") AreaRequest request);
|
||||
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="cn.stylefeng.roses.kernel.city.modular.mapper.AreaMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="cn.stylefeng.roses.kernel.city.modular.entity.Area">
|
||||
<id column="area_id" property="areaId"/>
|
||||
<result column="area_code" property="areaCode"/>
|
||||
<result column="area_name" property="areaName"/>
|
||||
<result column="parent_id" property="parentId"/>
|
||||
<result column="area_level" property="areaLevel"/>
|
||||
<result column="area_sort" property="areaSort"/>
|
||||
<result column="del_flag" property="delFlag"/>
|
||||
<result column="area_pids" property="areaPids"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="create_user" property="createUser"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="update_user" property="updateUser"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="customResultMap" type="cn.stylefeng.roses.kernel.city.modular.pojo.AreaVo" extends="BaseResultMap">
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
area_id
|
||||
,area_code,area_name,parent_id,area_level,area_sort,del_flag,area_pids,create_time,create_user,update_time,update_user
|
||||
</sql>
|
||||
|
||||
|
||||
<select id="selectAll" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM
|
||||
sys_area
|
||||
</select>
|
||||
|
||||
<select id="customFindList" resultMap="customResultMap">
|
||||
SELECT
|
||||
tbl.area_id,
|
||||
tbl.area_code,
|
||||
tbl.area_name,
|
||||
tbl.parent_id,
|
||||
tbl.area_level,
|
||||
tbl.area_sort,
|
||||
tbl.del_flag,
|
||||
tbl.area_pids,
|
||||
tbl.create_time,
|
||||
tbl.create_user,
|
||||
tbl.update_time,
|
||||
tbl.update_user
|
||||
|
||||
FROM
|
||||
sys_area tbl
|
||||
WHERE tbl.del_flag = 'N'
|
||||
<if test="param.areaId != null ">
|
||||
and tbl.area_id = #{param.areaId}
|
||||
</if>
|
||||
<if test="param.areaCode != null and param.areaCode != ''">
|
||||
and tbl.area_code like concat('%',#{param.areaCode},'%')
|
||||
</if>
|
||||
<if test="param.areaName != null and param.areaName != ''">
|
||||
and tbl.area_name like concat('%',#{param.areaName},'%')
|
||||
</if>
|
||||
<if test="param.parentId != null and param.parentId != ''">
|
||||
and tbl.parent_id like concat('%',#{param.parentId},'%')
|
||||
</if>
|
||||
<if test="param.areaLevel != null ">
|
||||
and tbl.area_level = #{param.areaLevel}
|
||||
</if>
|
||||
<if test="param.areaSort != null ">
|
||||
and tbl.area_sort = #{param.areaSort}
|
||||
</if>
|
||||
<if test="param.delFlag != null and param.delFlag != ''">
|
||||
and tbl.del_flag like concat('%',#{param.delFlag},'%')
|
||||
</if>
|
||||
<if test="param.areaPids != null and param.areaPids != ''">
|
||||
and tbl.area_pids like concat('%',#{param.areaPids},'%')
|
||||
</if>
|
||||
<if test="param.createTime != null ">
|
||||
and tbl.create_time = #{param.createTime}
|
||||
</if>
|
||||
<if test="param.createUser != null ">
|
||||
and tbl.create_user = #{param.createUser}
|
||||
</if>
|
||||
<if test="param.updateTime != null ">
|
||||
and tbl.update_time = #{param.updateTime}
|
||||
</if>
|
||||
<if test="param.updateUser != null ">
|
||||
and tbl.update_user = #{param.updateUser}
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package cn.stylefeng.roses.kernel.city.modular.pojo;
|
||||
|
||||
|
||||
import cn.stylefeng.roses.kernel.city.modular.entity.Area;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 行政区域实例类
|
||||
*
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
@Data
|
||||
public class AreaVo extends Area {
|
||||
|
||||
|
||||
}
|
|
@ -1,18 +1,16 @@
|
|||
package cn.stylefeng.roses.kernel.dict.modular.pojo.request;
|
||||
package cn.stylefeng.roses.kernel.city.modular.pojo.request;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 【系统基础】-【行政区域表】封装类
|
||||
* 行政区域封装类
|
||||
*
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
|
@ -1,22 +1,22 @@
|
|||
package cn.stylefeng.roses.kernel.dict.modular.service;
|
||||
package cn.stylefeng.roses.kernel.city.modular.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.city.modular.entity.Area;
|
||||
import cn.stylefeng.roses.kernel.city.modular.pojo.AreaVo;
|
||||
import cn.stylefeng.roses.kernel.city.modular.pojo.request.AreaRequest;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.dict.modular.entity.Area;
|
||||
import cn.stylefeng.roses.kernel.dict.modular.pojo.AreaVo;
|
||||
import cn.stylefeng.roses.kernel.dict.modular.pojo.request.AreaRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 【系统基础】-【行政区域表】 服务类
|
||||
* 行政区域 服务类
|
||||
*
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
public interface AreaService extends IService<Area> {
|
||||
|
||||
/**
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param areaRequest 请求参数
|
||||
|
@ -25,7 +25,7 @@ public interface AreaService extends IService<Area> {
|
|||
*/
|
||||
void add(AreaRequest areaRequest);
|
||||
|
||||
/**
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param areaRequest 请求参数
|
||||
|
@ -34,7 +34,7 @@ public interface AreaService extends IService<Area> {
|
|||
*/
|
||||
void del(AreaRequest areaRequest);
|
||||
|
||||
/**
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param areaRequest 请求参数
|
||||
|
@ -43,7 +43,7 @@ public interface AreaService extends IService<Area> {
|
|||
*/
|
||||
void edit(AreaRequest areaRequest);
|
||||
|
||||
/**
|
||||
/**
|
||||
* 查询详情
|
||||
*
|
||||
* @param areaRequest 请求参数
|
||||
|
@ -52,20 +52,20 @@ public interface AreaService extends IService<Area> {
|
|||
*/
|
||||
Area detail(AreaRequest areaRequest);
|
||||
|
||||
/**
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @param areaRequest 请求参数
|
||||
* @param areaRequest 请求参数
|
||||
* @return List<Area> 返回结果
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
List<Area> findList(AreaRequest areaRequest);
|
||||
|
||||
/**
|
||||
/**
|
||||
* 获取列表(带分页)
|
||||
*
|
||||
* @param areaRequest 请求参数
|
||||
* @param areaRequest 请求参数
|
||||
* @return PageResult<Area> 返回结果
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
|
@ -0,0 +1,123 @@
|
|||
package cn.stylefeng.roses.kernel.city.modular.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.city.modular.entity.Area;
|
||||
import cn.stylefeng.roses.kernel.city.modular.enums.AreaExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.city.modular.mapper.AreaMapper;
|
||||
import cn.stylefeng.roses.kernel.city.modular.pojo.AreaVo;
|
||||
import cn.stylefeng.roses.kernel.city.modular.pojo.request.AreaRequest;
|
||||
import cn.stylefeng.roses.kernel.city.modular.service.AreaService;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.rule.constants.TreeConstants;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 行政区域业务实现层
|
||||
*
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
@Service
|
||||
public class AreaServiceImpl extends ServiceImpl<AreaMapper, Area> implements AreaService {
|
||||
@Override
|
||||
public void add(AreaRequest areaRequest) {
|
||||
Area area = new Area();
|
||||
BeanUtil.copyProperties(areaRequest, area);
|
||||
this.save(area);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void del(AreaRequest areaRequest) {
|
||||
Area area = this.queryArea(areaRequest);
|
||||
this.removeById(area.getAreaId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(AreaRequest areaRequest) {
|
||||
Area area = this.queryArea(areaRequest);
|
||||
BeanUtil.copyProperties(areaRequest, area);
|
||||
this.updateById(area);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Area detail(AreaRequest areaRequest) {
|
||||
return this.queryArea(areaRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<AreaVo> findPage(AreaRequest areaRequest) {
|
||||
Page<AreaVo> page = PageFactory.defaultPage();
|
||||
List<AreaVo> list = baseMapper.customFindList(page, areaRequest);
|
||||
PageResult<AreaVo> pageResult = PageResultFactory.createPageResult(page.setRecords(list));
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Area> findList(AreaRequest areaRequest) {
|
||||
|
||||
LambdaQueryWrapper<Area> queryWrapper = new LambdaQueryWrapper<>();
|
||||
String parentId = areaRequest.getParentId();
|
||||
if (ObjectUtil.isEmpty(parentId)) {
|
||||
parentId = TreeConstants.DEFAULT_PARENT_ID.toString();
|
||||
}
|
||||
queryWrapper.select(Area::getAreaId, Area::getAreaName, Area::getAreaCode);
|
||||
queryWrapper.eq(Area::getParentId, parentId);
|
||||
queryWrapper.orderByAsc(Area::getAreaSort);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息
|
||||
*
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
private Area queryArea(AreaRequest areaRequest) {
|
||||
Area area = this.getById(areaRequest.getAreaId());
|
||||
if (ObjectUtil.isEmpty(area)) {
|
||||
throw new ServiceException(AreaExceptionEnum.AREA_NOT_EXISTED);
|
||||
}
|
||||
return area;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建查询wrapper
|
||||
*
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
private LambdaQueryWrapper<Area> createWrapper(AreaRequest areaRequest) {
|
||||
LambdaQueryWrapper<Area> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
Long areaId = areaRequest.getAreaId();
|
||||
String areaCode = areaRequest.getAreaCode();
|
||||
String areaName = areaRequest.getAreaName();
|
||||
String parentId = areaRequest.getParentId();
|
||||
Integer areaLevel = areaRequest.getAreaLevel();
|
||||
BigDecimal areaSort = areaRequest.getAreaSort();
|
||||
String delFlag = areaRequest.getDelFlag();
|
||||
String areaPids = areaRequest.getAreaPids();
|
||||
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(areaId), Area::getAreaId, areaId);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(areaCode), Area::getAreaCode, areaCode);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(areaName), Area::getAreaName, areaName);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(parentId), Area::getParentId, parentId);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(areaLevel), Area::getAreaLevel, areaLevel);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(areaSort), Area::getAreaSort, areaSort);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(delFlag), Area::getDelFlag, delFlag);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(areaPids), Area::getAreaPids, areaPids);
|
||||
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
}
|
|
@ -24,6 +24,13 @@
|
|||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--城市的字典业务-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>dict-city-business</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<modules>
|
||||
<module>dict-api</module>
|
||||
<module>dict-business</module>
|
||||
<module>dict-city-business</module>
|
||||
<module>dict-spring-boot-starter</module>
|
||||
</modules>
|
||||
|
||||
|
|
Loading…
Reference in New Issue