添加字段

This commit is contained in:
2026-01-22 11:06:37 +08:00
parent 84ebce764b
commit ac1512088f
9 changed files with 455 additions and 171 deletions

View File

@@ -2,197 +2,449 @@
```sql ```sql
/* ---------------------------------------------------- */ /* ---------------------------------------------------- */
/* Generated by Enterprise Architect Version 10.10 */ /* Generated by Enterprise Architect Version 10.10 */
/* Created On : 20-1月-2026 15:13:42 */ /* Created On : 22-1月-2026 10:57:00 */
/* DBMS : PostgreSQL */ /* DBMS : PostgreSQL */
/* ---------------------------------------------------- */ /* ---------------------------------------------------- */
/* Drop Sequences for Autonumber Columns */ /* Drop Sequences for Autonumber Columns */
DROP SEQUENCE IF EXISTS cg_template_id_seq;
DROP SEQUENCE IF EXISTS cg_template_id_seq
;
/* Drop Tables */ /* Drop Tables */
DROP TABLE IF EXISTS cg_fun_item CASCADE;
DROP TABLE IF EXISTS cg_fun_module CASCADE; DROP TABLE IF EXISTS cg_fun_item CASCADE
DROP TABLE IF EXISTS cg_fun_operation CASCADE; ;
DROP TABLE IF EXISTS cg_menu CASCADE;
DROP TABLE IF EXISTS cg_role CASCADE; DROP TABLE IF EXISTS cg_fun_module CASCADE
DROP TABLE IF EXISTS cg_role_fun CASCADE; ;
DROP TABLE IF EXISTS cg_template CASCADE;
DROP TABLE IF EXISTS cg_fun_operation CASCADE
;
DROP TABLE IF EXISTS cg_menu CASCADE
;
DROP TABLE IF EXISTS cg_role CASCADE
;
DROP TABLE IF EXISTS cg_role_fun CASCADE
;
DROP TABLE IF EXISTS cg_template CASCADE
;
/* Create Tables */ /* Create Tables */
CREATE TABLE cg_fun_item (
id bigint NOT NULL, -- id
module_id bigint NOT NULL, -- 模块ID
item_id bigint NOT NULL, -- 功能ID
item_name varchar(50) NOT NULL, -- 功能名称
item_code varchar(64) NOT NULL, -- 功能编码
is_tenant boolean NOT NULL DEFAULT true, -- 是否租户
describe varchar(250) NULL, -- 说明
sort_order smallint NOT NULL DEFAULT 0 -- 排序
);
CREATE TABLE cg_fun_module ( CREATE TABLE cg_fun_item
id bigint NOT NULL, -- id (
module_code varchar(16) NOT NULL, -- 模块编码 id bigint NOT NULL, -- id
module_name varchar(8) NOT NULL, -- 模块名称 module_id bigint NOT NULL, -- 模块ID
package_name varchar(250) NOT NULL, -- 包名称 item_id bigint NOT NULL, -- 功能ID
api_package_name varchar(250) NOT NULL, -- 参数包名 item_name varchar(50) NOT NULL, -- 功能名称
sort_order smallint NOT NULL DEFAULT 0, -- 排序 item_code varchar(64) NOT NULL, -- 功能编码
describe varchar(250) NULL -- 描述 is_tenant boolean NOT NULL DEFAULT true, -- 是否租户
); describe varchar(250) NULL, -- 说明
sort_order smallint NOT NULL DEFAULT 0 -- 排序
)
;
CREATE TABLE cg_fun_operation ( CREATE TABLE cg_fun_module
id bigint NOT NULL, -- id (
module_id bigint NOT NULL, -- 模块ID id bigint NOT NULL, -- id
item_id bigint NOT NULL, -- 功能ID(表主键ID) module_code varchar(16) NOT NULL, -- 模块编码
is_green_light boolean NOT NULL DEFAULT false, -- 直接放行 module_name varchar(8) NOT NULL, -- 模块名称
operation_id bigint NOT NULL, -- 操作ID package_name varchar(250) NOT NULL, -- 包名称
operation_code varchar(32) NULL, -- 操作编码 api_package_name varchar(250) NOT NULL, -- 参数包名
fun_name varchar(16) NOT NULL, -- 操作名称 sort_order smallint NOT NULL DEFAULT 0, -- 排序
fun_type smallint NOT NULL, -- 操作类型 > >查 > >改 > >删 > >增 describe varchar(250) NULL -- 描述
request_type smallint NOT NULL, -- 请求类型 )
is_req_params boolean NOT NULL DEFAULT true, -- 是否需要请求参数 ;
is_res_params boolean NOT NULL DEFAULT true, -- 是否需要响应参数
is_page boolean NOT NULL DEFAULT true, -- 是否分页
path_params varchar(16) NULL, -- 路径参数与请求参数true互斥
usable_config json NOT NULL DEFAULT '[]', -- 可配置数据类型json[]
field_config json NOT NULL DEFAULT '[]', -- 可配置字段
sort_order smallint NOT NULL DEFAULT 0, -- 排序
describe varchar(250) NULL -- 说明说明
);
CREATE TABLE cg_menu ( CREATE TABLE cg_fun_operation
id bigint NOT NULL, -- 主键ID (
client_type smallint NOT NULL, -- 客户端类型0 PC端1 小程序端2 H5端 id bigint NOT NULL, -- id
menu_name varchar(32) NOT NULL, -- 菜单名称 module_id bigint NOT NULL, -- 模块ID
parent_id bigint NOT NULL DEFAULT 0, -- 父菜单ID item_id bigint NOT NULL, -- 功能ID(表主键ID)
fun_id bigint NULL, -- 操作ID/来自操作表 is_green_light boolean NOT NULL DEFAULT false, -- 直接放行
menu_type smallint NOT NULL DEFAULT 0, -- 0菜单1按钮 operation_id bigint NOT NULL, -- 操作ID
path varchar(64) NULL, -- 路由路径 operation_code varchar(32) NULL, -- 操作编码
icon varchar(64) NULL, -- 菜单图标 fun_name varchar(16) NOT NULL, -- 操作名称
is_tenant boolean NOT NULL DEFAULT true, -- 是否租户 fun_type smallint NOT NULL, -- 操作类型>>查>>改>>删>>增
is_hide boolean NOT NULL DEFAULT false, -- 是否隐藏 request_type smallint NOT NULL, -- 请求类型
sort_order smallint NOT NULL DEFAULT 0 -- 排序 is_req_params boolean NOT NULL DEFAULT true, -- 是否需要请求参数
); is_res_params boolean NOT NULL DEFAULT true, -- 是否需要响应参数
is_page boolean NOT NULL DEFAULT true, -- 是否分页
path_params varchar(16) NULL, -- 路径参数与请求参数true互斥
usable_config json NOT NULL DEFAULT '[]', -- 可配置数据类型json[]
field_config json NOT NULL DEFAULT '[]', -- 可配置字段
sort_order smallint NOT NULL DEFAULT 0, -- 排序
describe varchar(250) NULL -- 说明说明
)
;
CREATE TABLE cg_role ( CREATE TABLE cg_menu
id bigint NOT NULL, -- 主键ID (
role_name varchar(32) NOT NULL, -- 角色名称 id bigint NOT NULL, -- 主键ID
role_type smallint NOT NULL -- 角色类型 0平台 1套餐 client_type smallint NOT NULL, -- 客户端类型0 PC端1 小程序端2 H5端
); menu_name varchar(32) NOT NULL, -- 菜单名称
parent_id bigint NOT NULL DEFAULT 0, -- 父菜单ID
fun_id bigint NULL, -- 操作ID/来自操作表
menu_type smallint NOT NULL DEFAULT 0, -- 0菜单1按钮
path varchar(64) NULL, -- 路由路径
page_path varchar(64) NULL,
icon varchar(64) NULL, -- 菜单图标
is_tenant boolean NOT NULL DEFAULT true, -- 是否租户
is_hide boolean NOT NULL DEFAULT false, -- 是否隐藏
sort_order smallint NOT NULL DEFAULT 0 -- 排序
)
;
CREATE TABLE cg_role_fun ( CREATE TABLE cg_role
id bigint NOT NULL, -- 主键ID (
role_id bigint NOT NULL, -- 角色ID id bigint NOT NULL, -- 主键ID
fun_id bigint NOT NULL, -- 操作ID role_name varchar(32) NOT NULL, -- 角色名称
data_scope smallint NOT NULL DEFAULT 0, -- 数据权限默认:0无 role_type smallint NOT NULL -- 角色类型 0平台 1套餐
assign_data_scope json NOT NULL DEFAULT '[]', -- 指定的数据权限范围 )
exclude_field json NOT NULL DEFAULT '[]', -- 排除的字段 ;
client_type smallserial NOT NULL -- 客户端类型0 PC端1 小程序端2 H5端
);
CREATE TABLE cg_template ( CREATE TABLE cg_role_fun
id bigint NOT NULL DEFAULT NEXTVAL(('"cg_template_id_seq"'::text)::regclass), -- 主键ID (
is_use boolean NOT NULL DEFAULT false, -- 是否使用 id bigint NOT NULL, -- 主键ID
template_name varchar(32) NOT NULL, -- 模板名称 role_id bigint NOT NULL, -- 角色ID
template_type smallint NOT NULL, -- 模板类型 fun_id bigint NOT NULL, -- 操作ID
content text NOT NULL -- 正文 data_scope smallint NOT NULL DEFAULT 0, -- 数据权限默认:0无
); assign_data_scope json NOT NULL DEFAULT '[]', -- 指定的数据权限范围
exclude_field json NOT NULL DEFAULT '[]', -- 排除的字段
client_type smallserial NOT NULL -- 客户端类型0 PC端1 小程序端2 H5端
)
;
CREATE TABLE cg_template
(
id bigint NOT NULL DEFAULT NEXTVAL(('"cg_template_id_seq"'::text)::regclass), -- 主键ID
is_use boolean NOT NULL DEFAULT false, -- 是否使用
template_name varchar(32) NOT NULL, -- 模板名称
template_type smallint NOT NULL, -- 模板类型
content text NOT NULL -- 正文
)
;
/* Create Primary Keys, Indexes, Uniques, Checks */ /* Create Primary Keys, Indexes, Uniques, Checks */
ALTER TABLE cg_fun_item ADD CONSTRAINT "PK_cg_fun_item" PRIMARY KEY (id);
ALTER TABLE cg_fun_item ADD CONSTRAINT u_module_item_code UNIQUE (module_id, item_id, item_code);
ALTER TABLE cg_fun_item ADD CONSTRAINT u_module_item_id UNIQUE (module_id, item_id);
ALTER TABLE cg_fun_module ADD CONSTRAINT "PK_cg_fun_module" PRIMARY KEY (id); ALTER TABLE cg_fun_item ADD CONSTRAINT "PK_cg_fun_item"
PRIMARY KEY (id)
;
ALTER TABLE cg_fun_operation ADD CONSTRAINT "PK_cg_fun_operation" PRIMARY KEY (id); ALTER TABLE cg_fun_item
ALTER TABLE cg_fun_operation ADD CONSTRAINT u_module_item_opration UNIQUE (module_id, item_id, operation_code); ADD CONSTRAINT u_module_item_code UNIQUE (module_id,item_id,item_code)
ALTER TABLE cg_fun_operation ADD CONSTRAINT u_module_item_operation_id UNIQUE (module_id, item_id, operation_id); ;
ALTER TABLE cg_menu ADD CONSTRAINT "PK_cg_menu" PRIMARY KEY (id); ALTER TABLE cg_fun_item
ADD CONSTRAINT u_module_item_id UNIQUE (module_id,item_id)
;
ALTER TABLE cg_role ADD CONSTRAINT "PK_cg_role" PRIMARY KEY (id); ALTER TABLE cg_fun_module ADD CONSTRAINT "PK_cg_fun_module"
PRIMARY KEY (id)
;
ALTER TABLE cg_role_fun ADD CONSTRAINT "PK_cg_role_fun" PRIMARY KEY (id); ALTER TABLE cg_fun_operation ADD CONSTRAINT "PK_cg_fun_operation"
PRIMARY KEY (id)
;
ALTER TABLE cg_template ADD CONSTRAINT "PK_cg_template" PRIMARY KEY (id); ALTER TABLE cg_fun_operation
ADD CONSTRAINT u_module_item_opration UNIQUE (module_id,item_id,operation_code)
;
ALTER TABLE cg_fun_operation
ADD CONSTRAINT u_module_item_operation_id UNIQUE (module_id,item_id,operation_id)
;
ALTER TABLE cg_menu ADD CONSTRAINT "PK_cg_menu"
PRIMARY KEY (id)
;
ALTER TABLE cg_role ADD CONSTRAINT "PK_cg_role"
PRIMARY KEY (id)
;
ALTER TABLE cg_role_fun ADD CONSTRAINT "PK_cg_role_fun"
PRIMARY KEY (id)
;
ALTER TABLE cg_template ADD CONSTRAINT "PK_cg_template"
PRIMARY KEY (id)
;
/* Create Table Comments, Sequences for Autonumber Columns */ /* Create Table Comments, Sequences for Autonumber Columns */
COMMENT ON TABLE cg_fun_item IS '功能项配置';
COMMENT ON COLUMN cg_fun_item.id IS 'id';
COMMENT ON COLUMN cg_fun_item.module_id IS '模块ID';
COMMENT ON COLUMN cg_fun_item.item_id IS '功能ID';
COMMENT ON COLUMN cg_fun_item.item_name IS '功能名称';
COMMENT ON COLUMN cg_fun_item.item_code IS '功能编码';
COMMENT ON COLUMN cg_fun_item.is_tenant IS '是否租户';
COMMENT ON COLUMN cg_fun_item.describe IS '说明';
COMMENT ON COLUMN cg_fun_item.sort_order IS '排序';
COMMENT ON TABLE cg_fun_module IS '模块配置'; COMMENT ON TABLE cg_fun_item
COMMENT ON COLUMN cg_fun_module.id IS 'id'; IS '功能项配置'
COMMENT ON COLUMN cg_fun_module.module_code IS '模块编码'; ;
COMMENT ON COLUMN cg_fun_module.module_name IS '模块名称';
COMMENT ON COLUMN cg_fun_module.package_name IS '包名称';
COMMENT ON COLUMN cg_fun_module.api_package_name IS '参数包名';
COMMENT ON COLUMN cg_fun_module.sort_order IS '排序';
COMMENT ON COLUMN cg_fun_module.describe IS '描述';
COMMENT ON TABLE cg_fun_operation IS '操作配置'; COMMENT ON COLUMN cg_fun_item.id
COMMENT ON COLUMN cg_fun_operation.id IS 'id'; IS 'id'
COMMENT ON COLUMN cg_fun_operation.module_id IS '模块ID'; ;
COMMENT ON COLUMN cg_fun_operation.item_id IS '功能ID(表主键ID)';
COMMENT ON COLUMN cg_fun_operation.is_green_light IS '直接放行';
COMMENT ON COLUMN cg_fun_operation.operation_id IS '操作ID';
COMMENT ON COLUMN cg_fun_operation.operation_code IS '操作编码';
COMMENT ON COLUMN cg_fun_operation.fun_name IS '操作名称';
COMMENT ON COLUMN cg_fun_operation.fun_type IS '操作类型 > >查 > >改 > >删 > >增';
COMMENT ON COLUMN cg_fun_operation.request_type IS '请求类型';
COMMENT ON COLUMN cg_fun_operation.is_req_params IS '是否需要请求参数';
COMMENT ON COLUMN cg_fun_operation.is_res_params IS '是否需要响应参数';
COMMENT ON COLUMN cg_fun_operation.is_page IS '是否分页';
COMMENT ON COLUMN cg_fun_operation.path_params IS '路径参数与请求参数true互斥';
COMMENT ON COLUMN cg_fun_operation.usable_config IS '可配置数据类型json[]';
COMMENT ON COLUMN cg_fun_operation.field_config IS '可配置字段';
COMMENT ON COLUMN cg_fun_operation.sort_order IS '排序';
COMMENT ON COLUMN cg_fun_operation.describe IS '说明说明';
COMMENT ON TABLE cg_menu IS '菜单'; COMMENT ON COLUMN cg_fun_item.module_id
COMMENT ON COLUMN cg_menu.id IS '主键ID'; IS '模块ID'
COMMENT ON COLUMN cg_menu.client_type IS '客户端类型0 PC端1 小程序端2 H5端'; ;
COMMENT ON COLUMN cg_menu.menu_name IS '菜单名称';
COMMENT ON COLUMN cg_menu.parent_id IS '父菜单ID';
COMMENT ON COLUMN cg_menu.fun_id IS '操作ID/来自操作表';
COMMENT ON COLUMN cg_menu.menu_type IS '0菜单1按钮';
COMMENT ON COLUMN cg_menu.path IS '路由路径';
COMMENT ON COLUMN cg_menu.icon IS '菜单图标';
COMMENT ON COLUMN cg_menu.is_tenant IS '是否租户';
COMMENT ON COLUMN cg_menu.is_hide IS '是否隐藏';
COMMENT ON COLUMN cg_menu.sort_order IS '排序';
COMMENT ON TABLE cg_role IS '角色表'; COMMENT ON COLUMN cg_fun_item.item_id
COMMENT ON COLUMN cg_role.id IS '主键ID'; IS '功能ID'
COMMENT ON COLUMN cg_role.role_name IS '角色名称'; ;
COMMENT ON COLUMN cg_role.role_type IS '角色类型 0平台 1套餐';
COMMENT ON TABLE cg_role_fun IS '角色权限表'; COMMENT ON COLUMN cg_fun_item.item_name
COMMENT ON COLUMN cg_role_fun.id IS '主键ID'; IS '功能名称'
COMMENT ON COLUMN cg_role_fun.role_id IS '角色ID'; ;
COMMENT ON COLUMN cg_role_fun.fun_id IS '操作ID';
COMMENT ON COLUMN cg_role_fun.data_scope IS '数据权限默认:0无';
COMMENT ON COLUMN cg_role_fun.assign_data_scope IS '指定的数据权限范围';
COMMENT ON COLUMN cg_role_fun.exclude_field IS '排除的字段';
COMMENT ON COLUMN cg_role_fun.client_type IS '客户端类型0 PC端1 小程序端2 H5端';
COMMENT ON TABLE cg_template IS '模板表'; COMMENT ON COLUMN cg_fun_item.item_code
COMMENT ON COLUMN cg_template.id IS '主键ID'; IS '功能编码'
COMMENT ON COLUMN cg_template.is_use IS '是否使用'; ;
COMMENT ON COLUMN cg_template.template_name IS '模板名称';
COMMENT ON COLUMN cg_template.template_type IS '模板类型'; COMMENT ON COLUMN cg_fun_item.is_tenant
COMMENT ON COLUMN cg_template.content IS '正文'; IS '是否租户'
;
COMMENT ON COLUMN cg_fun_item.describe
IS '说明'
;
COMMENT ON COLUMN cg_fun_item.sort_order
IS '排序'
;
COMMENT ON TABLE cg_fun_module
IS '模块配置'
;
COMMENT ON COLUMN cg_fun_module.id
IS 'id'
;
COMMENT ON COLUMN cg_fun_module.module_code
IS '模块编码'
;
COMMENT ON COLUMN cg_fun_module.module_name
IS '模块名称'
;
COMMENT ON COLUMN cg_fun_module.package_name
IS '包名称'
;
COMMENT ON COLUMN cg_fun_module.api_package_name
IS '参数包名'
;
COMMENT ON COLUMN cg_fun_module.sort_order
IS '排序'
;
COMMENT ON COLUMN cg_fun_module.describe
IS '描述'
;
COMMENT ON TABLE cg_fun_operation
IS '操作配置'
;
COMMENT ON COLUMN cg_fun_operation.id
IS 'id'
;
COMMENT ON COLUMN cg_fun_operation.module_id
IS '模块ID'
;
COMMENT ON COLUMN cg_fun_operation.item_id
IS '功能ID(表主键ID)'
;
COMMENT ON COLUMN cg_fun_operation.is_green_light
IS '直接放行'
;
COMMENT ON COLUMN cg_fun_operation.operation_id
IS '操作ID'
;
COMMENT ON COLUMN cg_fun_operation.operation_code
IS '操作编码'
;
COMMENT ON COLUMN cg_fun_operation.fun_name
IS '操作名称'
;
COMMENT ON COLUMN cg_fun_operation.fun_type
IS '操作类型>>查>>改>>删>>增'
;
COMMENT ON COLUMN cg_fun_operation.request_type
IS '请求类型'
;
COMMENT ON COLUMN cg_fun_operation.is_req_params
IS '是否需要请求参数'
;
COMMENT ON COLUMN cg_fun_operation.is_res_params
IS '是否需要响应参数'
;
COMMENT ON COLUMN cg_fun_operation.is_page
IS '是否分页'
;
COMMENT ON COLUMN cg_fun_operation.path_params
IS '路径参数与请求参数true互斥'
;
COMMENT ON COLUMN cg_fun_operation.usable_config
IS '可配置数据类型json[]'
;
COMMENT ON COLUMN cg_fun_operation.field_config
IS '可配置字段'
;
COMMENT ON COLUMN cg_fun_operation.sort_order
IS '排序'
;
COMMENT ON COLUMN cg_fun_operation.describe
IS '说明说明'
;
COMMENT ON TABLE cg_menu
IS '菜单'
;
COMMENT ON COLUMN cg_menu.id
IS '主键ID'
;
COMMENT ON COLUMN cg_menu.client_type
IS '客户端类型0 PC端1 小程序端2 H5端'
;
COMMENT ON COLUMN cg_menu.menu_name
IS '菜单名称'
;
COMMENT ON COLUMN cg_menu.parent_id
IS '父菜单ID'
;
COMMENT ON COLUMN cg_menu.fun_id
IS '操作ID/来自操作表'
;
COMMENT ON COLUMN cg_menu.menu_type
IS '0菜单1按钮'
;
COMMENT ON COLUMN cg_menu.path
IS '路由路径'
;
COMMENT ON COLUMN cg_menu.icon
IS '菜单图标'
;
COMMENT ON COLUMN cg_menu.is_tenant
IS '是否租户'
;
COMMENT ON COLUMN cg_menu.is_hide
IS '是否隐藏'
;
COMMENT ON COLUMN cg_menu.sort_order
IS '排序'
;
COMMENT ON TABLE cg_role
IS '角色表'
;
COMMENT ON COLUMN cg_role.id
IS '主键ID'
;
COMMENT ON COLUMN cg_role.role_name
IS '角色名称'
;
COMMENT ON COLUMN cg_role.role_type
IS '角色类型 0平台 1套餐'
;
COMMENT ON TABLE cg_role_fun
IS '角色权限表'
;
COMMENT ON COLUMN cg_role_fun.id
IS '主键ID'
;
COMMENT ON COLUMN cg_role_fun.role_id
IS '角色ID'
;
COMMENT ON COLUMN cg_role_fun.fun_id
IS '操作ID'
;
COMMENT ON COLUMN cg_role_fun.data_scope
IS '数据权限默认:0无'
;
COMMENT ON COLUMN cg_role_fun.assign_data_scope
IS '指定的数据权限范围'
;
COMMENT ON COLUMN cg_role_fun.exclude_field
IS '排除的字段'
;
COMMENT ON COLUMN cg_role_fun.client_type
IS '客户端类型0 PC端1 小程序端2 H5端'
;
COMMENT ON COLUMN cg_template.id
IS '主键ID'
;
COMMENT ON COLUMN cg_template.is_use
IS '是否使用'
;
COMMENT ON COLUMN cg_template.template_name
IS '模板名称'
;
COMMENT ON COLUMN cg_template.template_type
IS '模板类型'
;
COMMENT ON COLUMN cg_template.content
IS '正文'
;
CREATE SEQUENCE cg_template_id_seq INCREMENT 1 START 1
;
CREATE SEQUENCE cg_template_id_seq INCREMENT 1 START 1;
``` ```

View File

@@ -342,7 +342,7 @@ operationTemplate(operation) ::= <<
<changeSet id="insert-ms-fun-operation-data" author="xinghe"> <changeSet id="insert-ms-fun-operation-data" author="xinghe">
<comment>初始化操作数据</comment> <comment>初始化操作数据</comment>
$operation:{op | $operation:{op |
<insert tableName="ms_fun_item"> <insert tableName="ms_fun_operation">
<column name="id" value="$op.id$"/> <column name="id" value="$op.id$"/>
<column name="module_id" value="$op.moduleId$"/> <column name="module_id" value="$op.moduleId$"/>
<column name="item_id" value="$op.itemId$"/> <column name="item_id" value="$op.itemId$"/>
@@ -351,7 +351,7 @@ operationTemplate(operation) ::= <<
<column name="fun_name" value="$op.funName$"/> <column name="fun_name" value="$op.funName$"/>
<column name="fun_type" value="$funTypeAnnotations.(op.funType)$"/> <column name="fun_type" value="$funTypeAnnotations.(op.funType)$"/>
<column name="usable_config" value="$op.usableConfigJson$"/> <column name="usable_config" value="$op.usableConfigJson$"/>
<column name="field_cofnig" value="$op.fieldConfigJson$"/> <column name="field_config" value="$op.fieldConfigJson$"/>
<column name="sort_order" value="$op.sortOrder$"/> <column name="sort_order" value="$op.sortOrder$"/>
<column name="describe" value="$op.describe$"/> <column name="describe" value="$op.describe$"/>
</insert> </insert>

View File

@@ -5,20 +5,19 @@ import com.cczsa.xinghe.codegen.entity.enums.MenuTypeEnum;
import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType; import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table; import com.mybatisflex.annotation.Table;
import java.io.Serializable;
import java.io.Serial;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
/** /**
* 菜单 实体类。 * 菜单 实体类。
* *
* @author My * @author xiayb
* @since 0.0.1 * @since 0.0.1
*/ */
@Data @Data
@@ -68,6 +67,11 @@ public class MenuEntity extends BaseEntity implements Serializable {
*/ */
private String path; private String path;
/**
* 页面路径
*/
private String pagePath;
/** /**
* 菜单图标 * 菜单图标
*/ */

View File

@@ -29,4 +29,7 @@ public class FunItemQueryReq implements Serializable {
@Schema(description = "功能编码") @Schema(description = "功能编码")
private String itemCode; private String itemCode;
@Schema(description = "是否租户")
private Boolean isTenant;
} }

View File

@@ -4,6 +4,7 @@ import com.cczsa.xinghe.codegen.entity.enums.ClientTypeEnum;
import com.cczsa.xinghe.codegen.entity.enums.MenuTypeEnum; import com.cczsa.xinghe.codegen.entity.enums.MenuTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@@ -35,6 +36,10 @@ public class MenuAddReq implements Serializable {
@Schema(description = "父菜单ID") @Schema(description = "父菜单ID")
private Long parentId = 0L; private Long parentId = 0L;
@Pattern(
regexp = "^(?:$|/(?:[a-zA-Z0-9_=?#&-]+/)*[a-zA-Z0-9_=?#&-]+)$",
message = "路由路径格式不正确:必须以'/'开头,不能以'/'结尾,且只能包含字母、数字、下划线、横杠、等号、问号、井号、与号,以及分隔斜杠(不能连续)"
)
@Schema(description = "路由路径") @Schema(description = "路由路径")
private String path; private String path;

View File

@@ -7,7 +7,7 @@ import com.cczsa.xinghe.codegen.entity.MenuEntity;
/** /**
* 菜单 映射层。 * 菜单 映射层。
* *
* @author My * @author xiayb
* @since 0.0.1 * @since 0.0.1
*/ */
@Mapper @Mapper

View File

@@ -8,7 +8,7 @@ import java.io.Serial;
/** /**
* 菜单 表定义层。 * 菜单 表定义层。
* *
* @author My * @author xiayb
* @since 0.0.1 * @since 0.0.1
*/ */
public class MenuDef extends TableDef { public class MenuDef extends TableDef {
@@ -61,6 +61,11 @@ public class MenuDef extends TableDef {
*/ */
public final QueryColumn MENU_TYPE = new QueryColumn(this, "menu_type"); public final QueryColumn MENU_TYPE = new QueryColumn(this, "menu_type");
/**
* 页面路径
*/
public final QueryColumn PAGE_PATH = new QueryColumn(this, "page_path");
/** /**
* 父菜单ID * 父菜单ID
*/ */
@@ -84,7 +89,7 @@ public class MenuDef extends TableDef {
/** /**
* 默认字段,不包含逻辑删除或者 large 等字段。 * 默认字段,不包含逻辑删除或者 large 等字段。
*/ */
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, CLIENT_TYPE, MENU_NAME, PARENT_ID, FUN_ID, MENU_TYPE, PATH, ICON, IS_TENANT, IS_HIDE, SORT_ORDER}; public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, CLIENT_TYPE, MENU_NAME, PARENT_ID, FUN_ID, MENU_TYPE, PATH, PAGE_PATH, ICON, IS_TENANT, IS_HIDE, SORT_ORDER};
public MenuDef() { public MenuDef() {
super("", "cg_menu"); super("", "cg_menu");

View File

@@ -51,6 +51,7 @@ public class FunItemServiceImpl implements FunItemService {
.from(funItemDef) .from(funItemDef)
.join(funModuleDef).on(funItemDef.MODULE_ID.eq(funModuleDef.ID)) .join(funModuleDef).on(funItemDef.MODULE_ID.eq(funModuleDef.ID))
.eq(FunItemEntity::getModuleId, req.getModuleId(), ObjectUtil.areNotNull(req.getModuleId())) .eq(FunItemEntity::getModuleId, req.getModuleId(), ObjectUtil.areNotNull(req.getModuleId()))
.eq(FunItemEntity::getIsTenant, req.getIsTenant(), ObjectUtil.areNotNull(req.getIsTenant()))
.like(FunItemEntity::getItemName, req.getItemName(), StrUtil.isNotBlank(req.getItemName())) .like(FunItemEntity::getItemName, req.getItemName(), StrUtil.isNotBlank(req.getItemName()))
.like(FunItemEntity::getItemCode, req.getItemCode(), StrUtil.isNotBlank(req.getItemCode())) .like(FunItemEntity::getItemCode, req.getItemCode(), StrUtil.isNotBlank(req.getItemCode()))
.orderBy(FunItemEntity::getSortOrder, false); .orderBy(FunItemEntity::getSortOrder, false);

View File

@@ -4,6 +4,7 @@ import com.cczsa.xinghe.codegen.entity.FunOperationEntity;
import com.cczsa.xinghe.codegen.entity.MenuEntity; import com.cczsa.xinghe.codegen.entity.MenuEntity;
import com.cczsa.xinghe.codegen.entity.RoleEntity; import com.cczsa.xinghe.codegen.entity.RoleEntity;
import com.cczsa.xinghe.codegen.entity.RoleFunEntity; import com.cczsa.xinghe.codegen.entity.RoleFunEntity;
import com.cczsa.xinghe.codegen.entity.enums.RoleTypeEnum;
import com.cczsa.xinghe.codegen.entity.enums.UsableConfigEnum; import com.cczsa.xinghe.codegen.entity.enums.UsableConfigEnum;
import com.cczsa.xinghe.codegen.entity.req.role.RoleAddReq; import com.cczsa.xinghe.codegen.entity.req.role.RoleAddReq;
import com.cczsa.xinghe.codegen.entity.req.role.RoleBindFunReq; import com.cczsa.xinghe.codegen.entity.req.role.RoleBindFunReq;
@@ -212,6 +213,14 @@ public class RoleServiceImpl implements RoleService {
*/ */
@Override @Override
public XResult<List<RoleQueryFunRes>> queryRoleFun(RoleQueryFunReq req) { public XResult<List<RoleQueryFunRes>> queryRoleFun(RoleQueryFunReq req) {
// 获取角色
RoleEntity roleEntity = roleMapper.selectOneById(req.getRoleId());
if (roleEntity == null) {
return XResult.failed("角色不存在");
}
RoleTypeEnum roleType = roleEntity.getRoleType();
boolean isTenant = roleType == RoleTypeEnum.PACKAGE;
// 获取菜单 // 获取菜单
MenuDef menuDef = MenuDef.MENU_ENTITY; MenuDef menuDef = MenuDef.MENU_ENTITY;
FunOperationDef funOperationDef = FunOperationDef.FUN_OPERATION_ENTITY; FunOperationDef funOperationDef = FunOperationDef.FUN_OPERATION_ENTITY;
@@ -228,6 +237,7 @@ public class RoleServiceImpl implements RoleService {
.from(menuDef) .from(menuDef)
.leftJoin(funOperationDef).on(menuDef.FUN_ID.eq(funOperationDef.ID)) .leftJoin(funOperationDef).on(menuDef.FUN_ID.eq(funOperationDef.ID))
.eq(MenuEntity::getClientType, req.getClientType()) .eq(MenuEntity::getClientType, req.getClientType())
.eq(MenuEntity::getIsTenant, isTenant)
.orderBy(MenuEntity::getSortOrder, false); .orderBy(MenuEntity::getSortOrder, false);
List<RoleQueryFunRes> roleQueryFunList = menuMapper.selectListByQueryAs(queryMenu, RoleQueryFunRes.class); List<RoleQueryFunRes> roleQueryFunList = menuMapper.selectListByQueryAs(queryMenu, RoleQueryFunRes.class);
// 获取角色功能权限 // 获取角色功能权限
@@ -239,6 +249,10 @@ public class RoleServiceImpl implements RoleService {
.eq(RoleFunEntity::getRoleId, req.getRoleId()); .eq(RoleFunEntity::getRoleId, req.getRoleId());
List<RoleFunEntity> roleFunEntities = roleFunMapper.selectListByQuery(queryRoleFun); List<RoleFunEntity> roleFunEntities = roleFunMapper.selectListByQuery(queryRoleFun);
for (RoleQueryFunRes roleQueryFunRes : roleQueryFunList) { for (RoleQueryFunRes roleQueryFunRes : roleQueryFunList) {
if(isTenant){
roleQueryFunRes.setUsableConfig(new ArrayList<>());
roleQueryFunRes.setFieldConfig(new ArrayList<>());
}
// 获取菜单功能 // 获取菜单功能
RoleFunEntity roleFunEntity = roleFunEntities.stream() RoleFunEntity roleFunEntity = roleFunEntities.stream()
.filter(entity -> entity.getFunId().equals(roleQueryFunRes.getFunId())) .filter(entity -> entity.getFunId().equals(roleQueryFunRes.getFunId()))