From 215b5427ee46f4fa04ae776f9dd151efcaed1e8f Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Mon, 10 Jul 2023 23:13:55 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=908.0=E3=80=91=E3=80=90area=E3=80=91?= =?UTF-8?q?=E6=95=B4=E7=90=86area?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modular/controller/AreaController.java | 3 +- .../city/modular/mapper/AreaMapper.java | 8 -- .../modular/mapper/mapping/AreaMapper.xml | 89 ------------------- .../kernel/city/modular/pojo/AreaVo.java | 17 ---- .../city/modular/service/AreaService.java | 3 +- .../modular/service/impl/AreaServiceImpl.java | 43 ++++----- 6 files changed, 17 insertions(+), 146 deletions(-) delete mode 100644 kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/pojo/AreaVo.java diff --git a/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/controller/AreaController.java b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/controller/AreaController.java index c20e0d229..4e17c1b2d 100644 --- a/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/controller/AreaController.java +++ b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/controller/AreaController.java @@ -1,7 +1,6 @@ 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; @@ -95,7 +94,7 @@ public class AreaController { * @date 2023/07/05 18:12 */ @GetResource(name = "分页查询行政区域", path = "/area/page") - public ResponseData> page(AreaRequest areaRequest) { + public ResponseData> page(AreaRequest areaRequest) { return new SuccessResponseData<>(areaService.findPage(areaRequest)); } diff --git a/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/mapper/AreaMapper.java b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/mapper/AreaMapper.java index 28b1bd575..22a73296d 100644 --- a/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/mapper/AreaMapper.java +++ b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/mapper/AreaMapper.java @@ -1,13 +1,7 @@ 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 com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.apache.ibatis.annotations.Param; - -import java.util.List; /** * 行政区域 Mapper 接口 @@ -17,6 +11,4 @@ import java.util.List; */ public interface AreaMapper extends BaseMapper { - 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 index 2e4f7ff5f..3184343a5 100644 --- 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 @@ -2,95 +2,6 @@ - - - - - - - - - - - - - - - - - - - - - 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 deleted file mode 100644 index eafcc826f..000000000 --- a/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/pojo/AreaVo.java +++ /dev/null @@ -1,17 +0,0 @@ -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-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/service/AreaService.java b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/service/AreaService.java index 92b57d1d6..ef72f4d6e 100644 --- a/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/service/AreaService.java +++ b/kernel-s-dict/dict-city-business/src/main/java/cn/stylefeng/roses/kernel/city/modular/service/AreaService.java @@ -1,7 +1,6 @@ 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 com.baomidou.mybatisplus.extension.service.IService; @@ -70,6 +69,6 @@ public interface AreaService extends IService { * @author LiYanJun * @date 2023/07/05 18:12 */ - PageResult findPage(AreaRequest areaRequest); + PageResult findPage(AreaRequest areaRequest); } \ No newline at end of file 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 index c50bf4b46..e367befbe 100644 --- 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 @@ -5,7 +5,6 @@ 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; @@ -18,7 +17,6 @@ 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; /** @@ -29,6 +27,7 @@ import java.util.List; */ @Service public class AreaServiceImpl extends ServiceImpl implements AreaService { + @Override public void add(AreaRequest areaRequest) { Area area = new Area(); @@ -55,25 +54,25 @@ public class AreaServiceImpl extends ServiceImpl implements Ar } @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; + public PageResult findPage(AreaRequest areaRequest) { + LambdaQueryWrapper wrapper = this.createWrapper(areaRequest); + Page page = this.page(PageFactory.defaultPage(), wrapper); + return PageResultFactory.createPageResult(page); } @Override public List findList(AreaRequest areaRequest) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); String parentId = areaRequest.getParentId(); if (ObjectUtil.isEmpty(parentId)) { - parentId = TreeConstants.DEFAULT_PARENT_ID.toString(); + areaRequest.setParentId(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); + + LambdaQueryWrapper wrapper = this.createWrapper(areaRequest); + + wrapper.select(Area::getAreaId, Area::getAreaName, Area::getAreaCode); + + return this.list(wrapper); } /** @@ -99,23 +98,11 @@ public class AreaServiceImpl extends ServiceImpl implements Ar 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.isNotEmpty(parentId), Area::getParentId, parentId); - 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); + // 排序字段排序 + queryWrapper.orderByAsc(Area::getAreaSort); return queryWrapper; }