mirror of https://gitee.com/stylefeng/roses
【8.3.3】【role】初始化角色分类的基础类
parent
17c3ed0f88
commit
107dbdb529
|
@ -0,0 +1,114 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.role.controller;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
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;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.entity.RoleCategory;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.pojo.request.RoleCategoryRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.service.RoleCategoryService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色分类控制器
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
@RestController
|
||||
@ApiResource(name = "角色分类")
|
||||
public class RoleCategoryController {
|
||||
|
||||
@Resource
|
||||
private RoleCategoryService roleCategoryService;
|
||||
|
||||
/**
|
||||
* 添加角色分类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
@PostResource(name = "添加角色分类", path = "/roleCategory/add")
|
||||
public ResponseData<RoleCategory> add(@RequestBody @Validated(RoleCategoryRequest.add.class) RoleCategoryRequest roleCategoryRequest) {
|
||||
roleCategoryService.add(roleCategoryRequest);
|
||||
return new SuccessResponseData<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除角色分类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
@PostResource(name = "删除角色分类", path = "/roleCategory/delete")
|
||||
public ResponseData<?> delete(@RequestBody @Validated(RoleCategoryRequest.delete.class) RoleCategoryRequest roleCategoryRequest) {
|
||||
roleCategoryService.del(roleCategoryRequest);
|
||||
return new SuccessResponseData<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除角色分类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
@PostResource(name = "批量删除角色分类", path = "/roleCategory/batchDelete")
|
||||
public ResponseData<?> batchDelete(@RequestBody @Validated(BaseRequest.batchDelete.class) RoleCategoryRequest roleCategoryRequest) {
|
||||
roleCategoryService.batchDelete(roleCategoryRequest);
|
||||
return new SuccessResponseData<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑角色分类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
@PostResource(name = "编辑角色分类", path = "/roleCategory/edit")
|
||||
public ResponseData<?> edit(@RequestBody @Validated(RoleCategoryRequest.edit.class) RoleCategoryRequest roleCategoryRequest) {
|
||||
roleCategoryService.edit(roleCategoryRequest);
|
||||
return new SuccessResponseData<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看角色分类详情
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
@GetResource(name = "查看角色分类详情", path = "/roleCategory/detail")
|
||||
public ResponseData<RoleCategory> detail(@Validated(RoleCategoryRequest.detail.class) RoleCategoryRequest roleCategoryRequest) {
|
||||
return new SuccessResponseData<>(roleCategoryService.detail(roleCategoryRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色分类列表
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
@GetResource(name = "获取角色分类列表", path = "/roleCategory/list")
|
||||
public ResponseData<List<RoleCategory>> list(RoleCategoryRequest roleCategoryRequest) {
|
||||
return new SuccessResponseData<>(roleCategoryService.findList(roleCategoryRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色分类列表(带分页)
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
@GetResource(name = "获取角色分类列表(带分页)", path = "/roleCategory/page")
|
||||
public ResponseData<PageResult<RoleCategory>> page(RoleCategoryRequest roleCategoryRequest) {
|
||||
return new SuccessResponseData<>(roleCategoryService.findPage(roleCategoryRequest));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.role.entity;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 角色分类实例类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
@TableName("sys_role_category")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class RoleCategory extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@ChineseDescription("主键id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 父级角色分类id
|
||||
*/
|
||||
@TableField("category_parent_id")
|
||||
@ChineseDescription("父级角色分类id")
|
||||
private Long categoryParentId;
|
||||
|
||||
/**
|
||||
* 父级角色分类id集合
|
||||
*/
|
||||
@TableField("category_pids")
|
||||
@ChineseDescription("父级角色分类id集合")
|
||||
private String categoryPids;
|
||||
|
||||
/**
|
||||
* 角色分类名称
|
||||
*/
|
||||
@TableField("role_category_name")
|
||||
@ChineseDescription("角色分类名称")
|
||||
private String roleCategoryName;
|
||||
|
||||
/**
|
||||
* 角色分类类型:15-业务角色,20-公司角色
|
||||
*/
|
||||
@TableField("category_type")
|
||||
@ChineseDescription("角色分类类型:15-业务角色,20-公司角色")
|
||||
private Integer categoryType;
|
||||
|
||||
/**
|
||||
* 删除标记:Y-已删除,N-未删除
|
||||
*/
|
||||
@TableField(value = "del_flag", fill = FieldFill.INSERT)
|
||||
@ChineseDescription("删除标记:Y-已删除,N-未删除")
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 租户号
|
||||
*/
|
||||
@TableField(value = "tenant_id", fill = FieldFill.INSERT)
|
||||
@ChineseDescription("租户号")
|
||||
private Long tenantId;
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.role.enums;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 角色分类异常相关枚举
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
@Getter
|
||||
public enum RoleCategoryExceptionEnum implements AbstractExceptionEnum {
|
||||
|
||||
/**
|
||||
* 查询结果不存在
|
||||
*/
|
||||
ROLE_CATEGORY_NOT_EXISTED(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10001", "查询结果不存在");
|
||||
|
||||
/**
|
||||
* 错误编码
|
||||
*/
|
||||
private final String errorCode;
|
||||
|
||||
/**
|
||||
* 提示用户信息
|
||||
*/
|
||||
private final String userTip;
|
||||
|
||||
RoleCategoryExceptionEnum(String errorCode, String userTip) {
|
||||
this.errorCode = errorCode;
|
||||
this.userTip = userTip;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.role.mapper;
|
||||
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.entity.RoleCategory;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.pojo.request.RoleCategoryRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.pojo.response.RoleCategoryVo;
|
||||
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 接口
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
public interface RoleCategoryMapper extends BaseMapper<RoleCategory> {
|
||||
|
||||
/**
|
||||
* 获取自定义查询列表
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
List<RoleCategoryVo> customFindList(@Param("page") Page page, @Param("param")RoleCategoryRequest request);
|
||||
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
<?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.sys.modular.role.mapper.RoleCategoryMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="cn.stylefeng.roses.kernel.sys.modular.role.entity.RoleCategory">
|
||||
<id column="id" property="id" />
|
||||
<result column="category_parent_id" property="categoryParentId" />
|
||||
<result column="category_pids" property="categoryPids" />
|
||||
<result column="role_category_name" property="roleCategoryName" />
|
||||
<result column="category_type" property="categoryType" />
|
||||
<result column="del_flag" property="delFlag" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="create_user" property="createUser" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="update_user" property="updateUser" />
|
||||
<result column="tenant_id" property="tenantId" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,category_parent_id,category_pids,role_category_name,category_type,del_flag,create_time,create_user,update_time,update_user,tenant_id
|
||||
</sql>
|
||||
|
||||
<resultMap id="customResultMap" type="cn.stylefeng.roses.kernel.sys.modular.role.pojo.response.RoleCategoryVo" extends="BaseResultMap">
|
||||
</resultMap>
|
||||
|
||||
<select id="customFindList" resultMap="customResultMap">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
sys_role_category tbl
|
||||
WHERE
|
||||
<where>
|
||||
<if test="param.id != null and param.id != ''">
|
||||
and tbl.id like concat('%',#{param.id},'%')
|
||||
</if>
|
||||
<if test="param.categoryParentId != null and param.categoryParentId != ''">
|
||||
and tbl.category_parent_id like concat('%',#{param.categoryParentId},'%')
|
||||
</if>
|
||||
<if test="param.categoryPids != null and param.categoryPids != ''">
|
||||
and tbl.category_pids like concat('%',#{param.categoryPids},'%')
|
||||
</if>
|
||||
<if test="param.roleCategoryName != null and param.roleCategoryName != ''">
|
||||
and tbl.role_category_name like concat('%',#{param.roleCategoryName},'%')
|
||||
</if>
|
||||
<if test="param.categoryType != null and param.categoryType != ''">
|
||||
and tbl.category_type like concat('%',#{param.categoryType},'%')
|
||||
</if>
|
||||
<if test="param.delFlag != null and param.delFlag != ''">
|
||||
and tbl.del_flag like concat('%',#{param.delFlag},'%')
|
||||
</if>
|
||||
<if test="param.createTime != null and param.createTime != ''">
|
||||
and tbl.create_time like concat('%',#{param.createTime},'%')
|
||||
</if>
|
||||
<if test="param.createUser != null and param.createUser != ''">
|
||||
and tbl.create_user like concat('%',#{param.createUser},'%')
|
||||
</if>
|
||||
<if test="param.updateTime != null and param.updateTime != ''">
|
||||
and tbl.update_time like concat('%',#{param.updateTime},'%')
|
||||
</if>
|
||||
<if test="param.updateUser != null and param.updateUser != ''">
|
||||
and tbl.update_user like concat('%',#{param.updateUser},'%')
|
||||
</if>
|
||||
<if test="param.tenantId != null and param.tenantId != ''">
|
||||
and tbl.tenant_id like concat('%',#{param.tenantId},'%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,70 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.role.pojo.request;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色分类封装类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class RoleCategoryRequest extends BaseRequest {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@NotNull(message = "主键id不能为空", groups = {edit.class, delete.class})
|
||||
@ChineseDescription("主键id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 父级角色分类id
|
||||
*/
|
||||
@NotNull(message = "父级角色分类id不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("父级角色分类id")
|
||||
private Long categoryParentId;
|
||||
|
||||
/**
|
||||
* 父级角色分类id集合
|
||||
*/
|
||||
@NotBlank(message = "父级角色分类id集合不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("父级角色分类id集合")
|
||||
private String categoryPids;
|
||||
|
||||
/**
|
||||
* 角色分类名称
|
||||
*/
|
||||
@NotBlank(message = "角色分类名称不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("角色分类名称")
|
||||
private String roleCategoryName;
|
||||
|
||||
/**
|
||||
* 角色分类类型:15-业务角色,20-公司角色
|
||||
*/
|
||||
@NotNull(message = "角色分类类型:15-业务角色,20-公司角色不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("角色分类类型:15-业务角色,20-公司角色")
|
||||
private Integer categoryType;
|
||||
|
||||
/**
|
||||
* 租户号
|
||||
*/
|
||||
@ChineseDescription("租户号")
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 批量删除用的id集合
|
||||
*/
|
||||
@NotNull(message = "批量删除id集合不能为空", groups = batchDelete.class)
|
||||
@ChineseDescription("批量删除用的id集合")
|
||||
private List<Long> batchDeleteIdList;
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.role.pojo.response;
|
||||
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.entity.RoleCategory;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 角色分类返回值封装
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class RoleCategoryVo extends RoleCategory {
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.role.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.entity.RoleCategory;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.pojo.request.RoleCategoryRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色分类服务类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
public interface RoleCategoryService extends IService<RoleCategory> {
|
||||
|
||||
/**
|
||||
* 新增角色分类
|
||||
*
|
||||
* @param roleCategoryRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
void add(RoleCategoryRequest roleCategoryRequest);
|
||||
|
||||
/**
|
||||
* 删除角色分类
|
||||
*
|
||||
* @param roleCategoryRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
void del(RoleCategoryRequest roleCategoryRequest);
|
||||
|
||||
/**
|
||||
* 批量删除角色分类
|
||||
*
|
||||
* @param roleCategoryRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
void batchDelete(RoleCategoryRequest roleCategoryRequest);
|
||||
|
||||
/**
|
||||
* 编辑角色分类
|
||||
*
|
||||
* @param roleCategoryRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
void edit(RoleCategoryRequest roleCategoryRequest);
|
||||
|
||||
/**
|
||||
* 查询详情角色分类
|
||||
*
|
||||
* @param roleCategoryRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
RoleCategory detail(RoleCategoryRequest roleCategoryRequest);
|
||||
|
||||
/**
|
||||
* 获取角色分类列表
|
||||
*
|
||||
* @param roleCategoryRequest 请求参数
|
||||
* @return List<RoleCategory> 返回结果
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
List<RoleCategory> findList(RoleCategoryRequest roleCategoryRequest);
|
||||
|
||||
/**
|
||||
* 获取角色分类分页列表
|
||||
*
|
||||
* @param roleCategoryRequest 请求参数
|
||||
* @return PageResult<RoleCategory> 返回结果
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
PageResult<RoleCategory> findPage(RoleCategoryRequest roleCategoryRequest);
|
||||
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.role.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
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.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.entity.RoleCategory;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.enums.RoleCategoryExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.mapper.RoleCategoryMapper;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.pojo.request.RoleCategoryRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.service.RoleCategoryService;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 角色分类业务实现层
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
@Service
|
||||
public class RoleCategoryServiceImpl extends ServiceImpl<RoleCategoryMapper, RoleCategory> implements RoleCategoryService {
|
||||
|
||||
@Override
|
||||
public void add(RoleCategoryRequest roleCategoryRequest) {
|
||||
RoleCategory roleCategory = new RoleCategory();
|
||||
BeanUtil.copyProperties(roleCategoryRequest, roleCategory);
|
||||
this.save(roleCategory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void del(RoleCategoryRequest roleCategoryRequest) {
|
||||
RoleCategory roleCategory = this.queryRoleCategory(roleCategoryRequest);
|
||||
this.removeById(roleCategory.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchDelete(RoleCategoryRequest roleCategoryRequest) {
|
||||
this.removeByIds(roleCategoryRequest.getBatchDeleteIdList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(RoleCategoryRequest roleCategoryRequest) {
|
||||
RoleCategory roleCategory = this.queryRoleCategory(roleCategoryRequest);
|
||||
BeanUtil.copyProperties(roleCategoryRequest, roleCategory);
|
||||
this.updateById(roleCategory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleCategory detail(RoleCategoryRequest roleCategoryRequest) {
|
||||
return this.queryRoleCategory(roleCategoryRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<RoleCategory> findPage(RoleCategoryRequest roleCategoryRequest) {
|
||||
LambdaQueryWrapper<RoleCategory> wrapper = createWrapper(roleCategoryRequest);
|
||||
Page<RoleCategory> pageList = this.page(PageFactory.defaultPage(), wrapper);
|
||||
return PageResultFactory.createPageResult(pageList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleCategory> findList(RoleCategoryRequest roleCategoryRequest) {
|
||||
LambdaQueryWrapper<RoleCategory> wrapper = this.createWrapper(roleCategoryRequest);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
private RoleCategory queryRoleCategory(RoleCategoryRequest roleCategoryRequest) {
|
||||
RoleCategory roleCategory = this.getById(roleCategoryRequest.getId());
|
||||
if (ObjectUtil.isEmpty(roleCategory)) {
|
||||
throw new ServiceException(RoleCategoryExceptionEnum.ROLE_CATEGORY_NOT_EXISTED);
|
||||
}
|
||||
return roleCategory;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建查询wrapper
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2025/01/22 17:40
|
||||
*/
|
||||
private LambdaQueryWrapper<RoleCategory> createWrapper(RoleCategoryRequest roleCategoryRequest) {
|
||||
LambdaQueryWrapper<RoleCategory> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
Long id = roleCategoryRequest.getId();
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(id), RoleCategory::getId, id);
|
||||
|
||||
Long categoryParentId = roleCategoryRequest.getCategoryParentId();
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(categoryParentId), RoleCategory::getCategoryParentId, categoryParentId);
|
||||
|
||||
String categoryPids = roleCategoryRequest.getCategoryPids();
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(categoryPids), RoleCategory::getCategoryPids, categoryPids);
|
||||
|
||||
String roleCategoryName = roleCategoryRequest.getRoleCategoryName();
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(roleCategoryName), RoleCategory::getRoleCategoryName, roleCategoryName);
|
||||
|
||||
Integer categoryType = roleCategoryRequest.getCategoryType();
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(categoryType), RoleCategory::getCategoryType, categoryType);
|
||||
|
||||
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue