From dc0a1c991c3cb5e8a73a35a2e99aed270940cc4f Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Mon, 10 Jul 2023 21:17:07 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=908.0=E3=80=91=E3=80=90dict=E3=80=91?= =?UTF-8?q?=E5=8D=95=E7=8B=AC=E6=8A=BD=E5=87=BA=E8=A1=8C=E6=94=BF=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modular/mapper/mapping/AreaMapper.xml | 97 -------------- .../kernel/dict/modular/pojo/AreaVo.java | 18 --- .../modular/service/impl/AreaServiceImpl.java | 126 ------------------ kernel-s-dict/dict-city-business/README.md | 1 + kernel-s-dict/dict-city-business/pom.xml | 67 ++++++++++ .../modular/controller/AreaController.java | 15 +-- .../kernel/city}/modular/entity/Area.java | 5 +- .../modular/enums/AreaExceptionEnum.java | 6 +- .../city}/modular/mapper/AreaMapper.java | 14 +- .../modular/mapper/mapping/AreaMapper.xml | 96 +++++++++++++ .../kernel/city/modular/pojo/AreaVo.java | 17 +++ .../modular/pojo/request/AreaRequest.java | 8 +- .../city}/modular/service/AreaService.java | 26 ++-- .../modular/service/impl/AreaServiceImpl.java | 123 +++++++++++++++++ .../dict-spring-boot-starter/pom.xml | 7 + kernel-s-dict/pom.xml | 1 + 16 files changed, 348 insertions(+), 279 deletions(-) delete mode 100644 kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/mapper/mapping/AreaMapper.xml delete mode 100644 kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/pojo/AreaVo.java delete mode 100644 kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/impl/AreaServiceImpl.java create mode 100644 kernel-s-dict/dict-city-business/README.md create mode 100644 kernel-s-dict/dict-city-business/pom.xml rename kernel-s-dict/{dict-business/src/main/java/cn/stylefeng/roses/kernel/dict => dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city}/modular/controller/AreaController.java (85%) rename kernel-s-dict/{dict-business/src/main/java/cn/stylefeng/roses/kernel/dict => dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city}/modular/entity/Area.java (93%) rename kernel-s-dict/{dict-business/src/main/java/cn/stylefeng/roses/kernel/dict => dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city}/modular/enums/AreaExceptionEnum.java (81%) rename kernel-s-dict/{dict-business/src/main/java/cn/stylefeng/roses/kernel/dict => dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city}/modular/mapper/AreaMapper.java (53%) create mode 100644 kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/mapper/mapping/AreaMapper.xml create mode 100644 kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/pojo/AreaVo.java rename kernel-s-dict/{dict-business/src/main/java/cn/stylefeng/roses/kernel/dict => dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city}/modular/pojo/request/AreaRequest.java (92%) rename kernel-s-dict/{dict-business/src/main/java/cn/stylefeng/roses/kernel/dict => dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city}/modular/service/AreaService.java (75%) create mode 100644 kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/service/impl/AreaServiceImpl.java diff --git a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/mapper/mapping/AreaMapper.xml b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/mapper/mapping/AreaMapper.xml deleted file mode 100644 index 378d3f803..000000000 --- a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/mapper/mapping/AreaMapper.xml +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - area_id,area_code,area_name,parent_id,area_level,area_sort,del_flag,area_pids,create_time,create_user,update_time,update_user - - - - - - - - - - - - diff --git a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/pojo/AreaVo.java b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/pojo/AreaVo.java deleted file mode 100644 index 45aba74c1..000000000 --- a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/pojo/AreaVo.java +++ /dev/null @@ -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 { - - -} diff --git a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/impl/AreaServiceImpl.java b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/impl/AreaServiceImpl.java deleted file mode 100644 index e3b774137..000000000 --- a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/impl/AreaServiceImpl.java +++ /dev/null @@ -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 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 findPage(AreaRequest areaRequest) { - Page page = PageFactory.defaultPage(); - List list = baseMapper.customFindList(page, areaRequest); - PageResult pageResult = PageResultFactory.createPageResult(page.setRecords(list)); - return pageResult; - } - - @Override - public List findList(AreaRequest areaRequest) { - - LambdaQueryWrapper 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 createWrapper(AreaRequest areaRequest) { - LambdaQueryWrapper 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; - } - -} \ No newline at end of file diff --git a/kernel-s-dict/dict-city-business/README.md b/kernel-s-dict/dict-city-business/README.md new file mode 100644 index 000000000..01b0390d0 --- /dev/null +++ b/kernel-s-dict/dict-city-business/README.md @@ -0,0 +1 @@ +城市-省市县联动的字典 \ No newline at end of file diff --git a/kernel-s-dict/dict-city-business/pom.xml b/kernel-s-dict/dict-city-business/pom.xml new file mode 100644 index 000000000..1250e6a1b --- /dev/null +++ b/kernel-s-dict/dict-city-business/pom.xml @@ -0,0 +1,67 @@ + + + 4.0.0 + + + cn.stylefeng.roses + kernel-s-dict + 8.0.0 + ../pom.xml + + + dict-city-business + + jar + + + + + + cn.stylefeng.roses + dict-api + ${roses.version} + + + + + + cn.stylefeng.roses + cache-api + ${roses.version} + + + + + + cn.stylefeng.roses + scanner-api + ${roses.version} + + + + + + cn.stylefeng.roses + validator-api-table-unique + ${roses.version} + + + + + + cn.stylefeng.roses + db-sdk-mp + ${roses.version} + + + + + org.springframework.boot + spring-boot-starter-web + + + + + diff --git a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/controller/AreaController.java b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/controller/AreaController.java similarity index 85% rename from kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/controller/AreaController.java rename to kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/controller/AreaController.java index d743f6bcb..c20e0d229 100644 --- a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/controller/AreaController.java +++ b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/controller/AreaController.java @@ -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 diff --git a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/entity/Area.java b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/entity/Area.java similarity index 93% rename from kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/entity/Area.java rename to kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/entity/Area.java index 0af7fdaef..88c02ee3e 100644 --- a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/entity/Area.java +++ b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/entity/Area.java @@ -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 diff --git a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/enums/AreaExceptionEnum.java b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/enums/AreaExceptionEnum.java similarity index 81% rename from kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/enums/AreaExceptionEnum.java rename to kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/enums/AreaExceptionEnum.java index f375be82a..48c2656f8 100644 --- a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/enums/AreaExceptionEnum.java +++ b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/enums/AreaExceptionEnum.java @@ -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", "查询结果不存在"); /** * 错误编码 diff --git a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/mapper/AreaMapper.java b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/mapper/AreaMapper.java similarity index 53% rename from kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/mapper/AreaMapper.java rename to kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/mapper/AreaMapper.java index 90b9f005c..28b1bd575 100644 --- a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/mapper/AreaMapper.java +++ b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/mapper/AreaMapper.java @@ -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 { - List customFindList(@Param("page") Page page, @Param("param")AreaRequest request); + List customFindList(@Param("page") Page page, @Param("param") AreaRequest request); } \ No newline at end of file diff --git a/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/mapper/mapping/AreaMapper.xml b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/mapper/mapping/AreaMapper.xml new file mode 100644 index 000000000..2e4f7ff5f --- /dev/null +++ b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/mapper/mapping/AreaMapper.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + area_id + ,area_code,area_name,parent_id,area_level,area_sort,del_flag,area_pids,create_time,create_user,update_time,update_user + + + + + + + + + + diff --git a/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/pojo/AreaVo.java b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/pojo/AreaVo.java new file mode 100644 index 000000000..eafcc826f --- /dev/null +++ b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/pojo/AreaVo.java @@ -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 { + + +} diff --git a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/pojo/request/AreaRequest.java b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/pojo/request/AreaRequest.java similarity index 92% rename from kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/pojo/request/AreaRequest.java rename to kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/pojo/request/AreaRequest.java index 622497a68..b09b84983 100644 --- a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/pojo/request/AreaRequest.java +++ b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/pojo/request/AreaRequest.java @@ -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 diff --git a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/AreaService.java b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/service/AreaService.java similarity index 75% rename from kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/AreaService.java rename to kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/service/AreaService.java index 762143321..92b57d1d6 100644 --- a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/AreaService.java +++ b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/service/AreaService.java @@ -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 { - /** + /** * 新增 * * @param areaRequest 请求参数 @@ -25,7 +25,7 @@ public interface AreaService extends IService { */ void add(AreaRequest areaRequest); - /** + /** * 删除 * * @param areaRequest 请求参数 @@ -34,7 +34,7 @@ public interface AreaService extends IService { */ void del(AreaRequest areaRequest); - /** + /** * 编辑 * * @param areaRequest 请求参数 @@ -43,7 +43,7 @@ public interface AreaService extends IService { */ void edit(AreaRequest areaRequest); - /** + /** * 查询详情 * * @param areaRequest 请求参数 @@ -52,20 +52,20 @@ public interface AreaService extends IService { */ Area detail(AreaRequest areaRequest); - /** + /** * 获取列表 * - * @param areaRequest 请求参数 + * @param areaRequest 请求参数 * @return List 返回结果 * @author LiYanJun * @date 2023/07/05 18:12 */ List findList(AreaRequest areaRequest); - /** + /** * 获取列表(带分页) * - * @param areaRequest 请求参数 + * @param areaRequest 请求参数 * @return PageResult 返回结果 * @author LiYanJun * @date 2023/07/05 18:12 diff --git a/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/service/impl/AreaServiceImpl.java b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/service/impl/AreaServiceImpl.java new file mode 100644 index 000000000..c50bf4b46 --- /dev/null +++ b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/service/impl/AreaServiceImpl.java @@ -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 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 findPage(AreaRequest areaRequest) { + Page page = PageFactory.defaultPage(); + List list = baseMapper.customFindList(page, areaRequest); + PageResult pageResult = PageResultFactory.createPageResult(page.setRecords(list)); + return pageResult; + } + + @Override + public List findList(AreaRequest areaRequest) { + + LambdaQueryWrapper 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 createWrapper(AreaRequest areaRequest) { + LambdaQueryWrapper 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; + } + +} \ No newline at end of file diff --git a/kernel-s-dict/dict-spring-boot-starter/pom.xml b/kernel-s-dict/dict-spring-boot-starter/pom.xml index 81f72931e..523220bf6 100644 --- a/kernel-s-dict/dict-spring-boot-starter/pom.xml +++ b/kernel-s-dict/dict-spring-boot-starter/pom.xml @@ -24,6 +24,13 @@ ${roses.version} + + + cn.stylefeng.roses + dict-city-business + ${roses.version} + + diff --git a/kernel-s-dict/pom.xml b/kernel-s-dict/pom.xml index 19f99ec77..789b8761f 100644 --- a/kernel-s-dict/pom.xml +++ b/kernel-s-dict/pom.xml @@ -18,6 +18,7 @@ dict-api dict-business + dict-city-business dict-spring-boot-starter