mirror of https://gitee.com/stylefeng/roses
获取行政区域列表
parent
c1bd8b746c
commit
1cb7700e3c
|
@ -0,0 +1,102 @@
|
|||
package cn.stylefeng.roses.kernel.dict.modular.controller;
|
||||
|
||||
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.scanner.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 【系统基础】-【行政区域表】控制器
|
||||
*
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
@RestController
|
||||
@ApiResource(name = "行政区域表")
|
||||
public class AreaController {
|
||||
|
||||
@Resource
|
||||
private AreaService areaService;
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
@PostResource(name = "添加行政区域", path = "/area/add")
|
||||
public ResponseData<Area> add(@RequestBody @Validated(AreaRequest.add.class) AreaRequest areaRequest) {
|
||||
areaService.add(areaRequest);
|
||||
return new SuccessResponseData<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
@PostResource(name = "删除行政区域", path = "/area/delete")
|
||||
public ResponseData<?> delete(@RequestBody @Validated(AreaRequest.delete.class) AreaRequest areaRequest) {
|
||||
areaService.del(areaRequest);
|
||||
return new SuccessResponseData<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
@PostResource(name = "编辑行政区域", path = "/area/edit")
|
||||
public ResponseData<?> edit(@RequestBody @Validated(AreaRequest.edit.class) AreaRequest areaRequest) {
|
||||
areaService.edit(areaRequest);
|
||||
return new SuccessResponseData<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看详情
|
||||
*
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
@GetResource(name = "查看行政区域详情", path = "/area/detail")
|
||||
public ResponseData<Area> detail(@Validated(AreaRequest.detail.class) AreaRequest areaRequest) {
|
||||
return new SuccessResponseData<>(areaService.detail(areaRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
@GetResource(name = "获取行政区域列表", path = "/area/list")
|
||||
public ResponseData<List<Area>> list(AreaRequest areaRequest) {
|
||||
return new SuccessResponseData<>(areaService.findList(areaRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列表(带分页)
|
||||
*
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
@GetResource(name = "分页查询行政区域", path = "/area/page")
|
||||
public ResponseData<PageResult<AreaVo>> page(AreaRequest areaRequest) {
|
||||
return new SuccessResponseData<>(areaService.findPage(areaRequest));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package cn.stylefeng.roses.kernel.dict.modular.entity;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
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
|
||||
*/
|
||||
@TableName("sys_area")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class Area extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 区域id
|
||||
*/
|
||||
@TableId(value = "area_id", type = IdType.ASSIGN_ID)
|
||||
@ChineseDescription("区域id")
|
||||
private Long areaId;
|
||||
|
||||
/**
|
||||
* 区域编码
|
||||
*/
|
||||
@TableField("area_code")
|
||||
@ChineseDescription("区域编码")
|
||||
private String areaCode;
|
||||
|
||||
/**
|
||||
* 区域全称
|
||||
*/
|
||||
@TableField("area_name")
|
||||
@ChineseDescription("区域全称")
|
||||
private String areaName;
|
||||
|
||||
/**
|
||||
* 上级区域编码
|
||||
*/
|
||||
@TableField("parent_id")
|
||||
@ChineseDescription("上级区域编码")
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 区域级别
|
||||
*/
|
||||
@TableField("area_level")
|
||||
@ChineseDescription("区域级别")
|
||||
private Integer areaLevel;
|
||||
|
||||
/**
|
||||
* 排序码
|
||||
*/
|
||||
@TableField("area_sort")
|
||||
@ChineseDescription("排序码")
|
||||
private BigDecimal areaSort;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
@TableField("del_flag")
|
||||
@ChineseDescription("是否删除")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 所有的上级区域编码,用逗号分隔
|
||||
*/
|
||||
@TableField("area_pids")
|
||||
@ChineseDescription("所有的上级区域编码,用逗号分隔")
|
||||
private String areaPids;
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package cn.stylefeng.roses.kernel.dict.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
|
||||
*/
|
||||
@Getter
|
||||
public enum AreaExceptionEnum implements AbstractExceptionEnum {
|
||||
|
||||
/**
|
||||
* 查询结果不存在
|
||||
*/
|
||||
AREA_NOT_EXISTED(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10001", "查询结果不存在");
|
||||
|
||||
/**
|
||||
* 错误编码
|
||||
*/
|
||||
private final String errorCode;
|
||||
|
||||
/**
|
||||
* 提示用户信息
|
||||
*/
|
||||
private final String userTip;
|
||||
|
||||
AreaExceptionEnum(String errorCode, String userTip) {
|
||||
this.errorCode = errorCode;
|
||||
this.userTip = userTip;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package cn.stylefeng.roses.kernel.dict.modular.mapper;
|
||||
|
||||
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 接口
|
||||
*
|
||||
* @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);
|
||||
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
<?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.vo.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,18 @@
|
|||
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 {
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package cn.stylefeng.roses.kernel.dict.modular.pojo.request;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
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
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class AreaRequest extends BaseRequest {
|
||||
|
||||
/**
|
||||
* 区域id
|
||||
*/
|
||||
@NotNull(message = "区域id不能为空", groups = {edit.class, delete.class})
|
||||
@ChineseDescription("区域id")
|
||||
private Long areaId;
|
||||
|
||||
/**
|
||||
* 区域编码
|
||||
*/
|
||||
@NotBlank(message = "区域编码不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("区域编码")
|
||||
private String areaCode;
|
||||
|
||||
/**
|
||||
* 区域全称
|
||||
*/
|
||||
@NotBlank(message = "区域全称不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("区域全称")
|
||||
private String areaName;
|
||||
|
||||
/**
|
||||
* 上级区域编码
|
||||
*/
|
||||
@NotBlank(message = "上级区域编码不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("上级区域编码")
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 区域级别
|
||||
*/
|
||||
@ChineseDescription("区域级别")
|
||||
private Integer areaLevel;
|
||||
|
||||
/**
|
||||
* 排序码
|
||||
*/
|
||||
@ChineseDescription("排序码")
|
||||
private BigDecimal areaSort;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
@ChineseDescription("是否删除")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 所有的上级区域编码,用逗号分隔
|
||||
*/
|
||||
@ChineseDescription("所有的上级区域编码,用逗号分隔")
|
||||
private String areaPids;
|
||||
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package cn.stylefeng.roses.kernel.dict.modular.service;
|
||||
|
||||
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 请求参数
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
void add(AreaRequest areaRequest);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param areaRequest 请求参数
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
void del(AreaRequest areaRequest);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param areaRequest 请求参数
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
void edit(AreaRequest areaRequest);
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*
|
||||
* @param areaRequest 请求参数
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
Area detail(AreaRequest areaRequest);
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @param areaRequest 请求参数
|
||||
* @return List<Area> 返回结果
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
List<Area> findList(AreaRequest areaRequest);
|
||||
|
||||
/**
|
||||
* 获取列表(带分页)
|
||||
*
|
||||
* @param areaRequest 请求参数
|
||||
* @return PageResult<Area> 返回结果
|
||||
* @author LiYanJun
|
||||
* @date 2023/07/05 18:12
|
||||
*/
|
||||
PageResult<AreaVo> findPage(AreaRequest areaRequest);
|
||||
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
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.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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue