【8.3.3】【role】增加角色的排序字段

dev-8.3.3
stylefeng 2025-01-22 17:59:27 +08:00
parent 107dbdb529
commit 028a55fd53
4 changed files with 60 additions and 8 deletions

View File

@ -2,20 +2,24 @@ 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 cn.stylefeng.roses.kernel.rule.tree.factory.base.AbstractTreeNode;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.List;
/**
*
*
* @author fengshuonan
* @since 2025/01/22 17:40
* @since 2025/01/22 17:51
*/
@TableName("sys_role_category")
@Data
@EqualsAndHashCode(callSuper = true)
public class RoleCategory extends BaseEntity {
public class RoleCategory extends BaseEntity implements AbstractTreeNode<RoleCategory> {
/**
* id
@ -52,6 +56,13 @@ public class RoleCategory extends BaseEntity {
@ChineseDescription("角色分类类型15-业务角色20-公司角色")
private Integer categoryType;
/**
*
*/
@TableField("fld_sort")
@ChineseDescription("角色分类排序")
private BigDecimal fldSort;
/**
* Y-N-
*/
@ -67,4 +78,31 @@ public class RoleCategory extends BaseEntity {
@ChineseDescription("租户号")
private Long tenantId;
/**
*
*/
@TableField(exist = false)
@ChineseDescription("角色类型子节点")
private List<RoleCategory> children;
@Override
public String getNodeId() {
if (id == null) {
return "";
}
return id.toString();
}
@Override
public String getNodeParentId() {
if (this.categoryParentId == null) {
return "";
}
return this.categoryParentId.toString();
}
@Override
public void setChildrenNodes(List<RoleCategory> childrenNodes) {
this.children = childrenNodes;
}
}

View File

@ -9,6 +9,7 @@
<result column="category_pids" property="categoryPids" />
<result column="role_category_name" property="roleCategoryName" />
<result column="category_type" property="categoryType" />
<result column="fld_sort" property="fldSort" />
<result column="del_flag" property="delFlag" />
<result column="create_time" property="createTime" />
<result column="create_user" property="createUser" />
@ -18,7 +19,7 @@
</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
id,category_parent_id,category_pids,role_category_name,category_type,fld_sort,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">
@ -46,6 +47,9 @@
<if test="param.categoryType != null and param.categoryType != ''">
and tbl.category_type like concat('%',#{param.categoryType},'%')
</if>
<if test="param.fldSort != null and param.fldSort != ''">
and tbl.fld_sort like concat('%',#{param.fldSort},'%')
</if>
<if test="param.delFlag != null and param.delFlag != ''">
and tbl.del_flag like concat('%',#{param.delFlag},'%')
</if>

View File

@ -7,13 +7,14 @@ import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.List;
/**
*
*
* @author fengshuonan
* @since 2025/01/22 17:40
* @since 2025/01/22 17:51
*/
@EqualsAndHashCode(callSuper = true)
@Data
@ -50,10 +51,16 @@ public class RoleCategoryRequest extends BaseRequest {
/**
* 15-20-
*/
@NotNull(message = "角色分类类型15-业务角色20-公司角色不能为空", groups = {add.class, edit.class})
@NotNull(message = "角色分类类型15-业务角色20-公司角色不能为空", groups = {add.class, edit.class, list.class})
@ChineseDescription("角色分类类型15-业务角色20-公司角色")
private Integer categoryType;
/**
*
*/
@ChineseDescription("角色分类排序")
private BigDecimal fldSort;
/**
*
*/

View File

@ -4,6 +4,7 @@ CREATE TABLE `sys_role_category` (
`category_pids` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '父级角色分类id集合',
`role_category_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色分类名称',
`category_type` tinyint NOT NULL DEFAULT '1' COMMENT '角色分类类型15-业务角色20-公司角色',
`fld_sort` decimal(10,2) DEFAULT NULL COMMENT '角色分类排序',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'N' COMMENT '删除标记Y-已删除N-未删除',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`create_user` bigint DEFAULT NULL COMMENT '创建人',
@ -14,9 +15,11 @@ CREATE TABLE `sys_role_category` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='角色分类';
-- 创建默认的类型
INSERT INTO `sys_role_category`(`id`, `category_parent_id`, `category_pids`, `role_category_name`, `category_type`, `del_flag`, `create_time`, `create_user`, `update_time`, `update_user`, `tenant_id`) VALUES (1881997026537611265, -1, '[-1],', '默认业务分类', 15, 'N', '2025-01-22 17:26:26', 1339550467939639299, NULL, NULL, NULL);
INSERT INTO `sys_role_category`(`id`, `category_parent_id`, `category_pids`, `role_category_name`, `category_type`, `del_flag`, `create_time`, `create_user`, `update_time`, `update_user`, `tenant_id`) VALUES (1881997160612732930, -1, '[-1],', '默认公司分类', 20, 'N', '2025-01-22 17:27:01', 1339550467939639299, NULL, NULL, NULL);
INSERT INTO `sys_role_category`(`id`, `category_parent_id`, `category_pids`, `role_category_name`, `category_type`, `fld_sort`, `del_flag`, `create_time`, `create_user`, `update_time`, `update_user`, `tenant_id`) VALUES (1881997026537611265, -1, '[-1],', '默认业务分类', 15, 100.00, 'N', '2025-01-22 17:26:26', 1339550467939639299, NULL, NULL, NULL);
INSERT INTO `sys_role_category`(`id`, `category_parent_id`, `category_pids`, `role_category_name`, `category_type`, `fld_sort`, `del_flag`, `create_time`, `create_user`, `update_time`, `update_user`, `tenant_id`) VALUES (1881997160612732930, -1, '[-1],', '默认公司分类', 20, 100.00, 'N', '2025-01-22 17:27:01', 1339550467939639299, NULL, NULL, NULL);
-- 角色增加分类id
ALTER TABLE `sys_role`
ADD COLUMN `role_category_id` bigint NULL COMMENT '所属的角色分类id如果是业务角色和公司角色可以加上所属分类' AFTER `role_type`;
ADD COLUMN `role_category_id` bigint NULL COMMENT '所属的角色分类id如果是业务角色和公司角色可以加上所属分类' AFTER `role_type`;
UPDATE `sys_role` SET `role_category_id` = 1881997026537611265 WHERE `role_type` = 15;
UPDATE `sys_role` SET `role_category_id` = 1881997160612732930 WHERE `role_type` = 20;