mirror of https://gitee.com/stylefeng/roses
【8.0】【area】整理area
parent
dc0a1c991c
commit
215b5427ee
|
@ -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<PageResult<AreaVo>> page(AreaRequest areaRequest) {
|
||||
public ResponseData<PageResult<Area>> page(AreaRequest areaRequest) {
|
||||
return new SuccessResponseData<>(areaService.findPage(areaRequest));
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Area> {
|
||||
|
||||
List<AreaVo> customFindList(@Param("page") Page page, @Param("param") AreaRequest request);
|
||||
|
||||
}
|
|
@ -2,95 +2,6 @@
|
|||
<!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>
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
||||
}
|
|
@ -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<Area> {
|
|||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
PageResult<AreaVo> findPage(AreaRequest areaRequest);
|
||||
PageResult<Area> findPage(AreaRequest areaRequest);
|
||||
|
||||
}
|
|
@ -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<AreaMapper, Area> implements AreaService {
|
||||
|
||||
@Override
|
||||
public void add(AreaRequest areaRequest) {
|
||||
Area area = new Area();
|
||||
|
@ -55,25 +54,25 @@ public class AreaServiceImpl extends ServiceImpl<AreaMapper, Area> implements Ar
|
|||
}
|
||||
|
||||
@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;
|
||||
public PageResult<Area> findPage(AreaRequest areaRequest) {
|
||||
LambdaQueryWrapper<Area> wrapper = this.createWrapper(areaRequest);
|
||||
Page<Area> page = this.page(PageFactory.defaultPage(), wrapper);
|
||||
return PageResultFactory.createPageResult(page);
|
||||
}
|
||||
|
||||
@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();
|
||||
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<Area> 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<AreaMapper, Area> implements Ar
|
|||
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.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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue