From 33c865f03c984ff5ce120b37286e3fcf0050775b Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Mon, 23 Oct 2023 17:26:14 +0800 Subject: [PATCH] Add permission-related database tables --- .../resources/db/migration/R__Basic_data.sql | 70 +++++++++++++++++++ ...1_0_0_231023__Add_table_'t_power_type'.sql | 7 ++ .../V1_0_0_231024__Add_table_'t_power'.sql | 7 ++ .../V1_0_0_231025__Add_table_'t_menu'.sql | 10 +++ .../V1_0_0_231026__Add_table_'t_element'.sql | 9 +++ ...V1_0_0_231027__Add_table_'t_operation'.sql | 11 +++ 6 files changed, 114 insertions(+) create mode 100644 src/main/resources/db/migration/R__Basic_data.sql create mode 100644 src/main/resources/db/migration/V1_0_0_231023__Add_table_'t_power_type'.sql create mode 100644 src/main/resources/db/migration/V1_0_0_231024__Add_table_'t_power'.sql create mode 100644 src/main/resources/db/migration/V1_0_0_231025__Add_table_'t_menu'.sql create mode 100644 src/main/resources/db/migration/V1_0_0_231026__Add_table_'t_element'.sql create mode 100644 src/main/resources/db/migration/V1_0_0_231027__Add_table_'t_operation'.sql diff --git a/src/main/resources/db/migration/R__Basic_data.sql b/src/main/resources/db/migration/R__Basic_data.sql new file mode 100644 index 0000000..6dfc7db --- /dev/null +++ b/src/main/resources/db/migration/R__Basic_data.sql @@ -0,0 +1,70 @@ +insert into t_power_type (id, name) +values (1, 'menu'), + (2, 'element'), + (3, 'operation') +on duplicate key update name = values(name); + +insert into t_power (id, type_id) +values (1010000, 1), + (1010100, 2), + (1010101, 3), + (101010000, 1), + (101010100, 2), + (101010101, 3), + (101010102, 3), + (101010103, 3), + (101010104, 3), + (102010000, 1), + (102010100, 2), + (102010101, 3), + (102010102, 3), + (102010103, 3), + (102010104, 3), + (103010000, 1), + (103010100, 2), + (103010101, 3), + (103010102, 3), + (103010103, 3), + (103010104, 3), + (103010105, 3) +on duplicate key update type_id = values(type_id); + +insert into t_menu (id, name, url, power_id, parent_id) +values (1010000, '公用', '/', id, null), + (101010000, '角色管理(权限相关)', '/power/role', id, null), + (102010000, '用户组管理(权限相关)', '/power/group', id, null), + (103010000, '用户管理(权限相关)', '/power/user', id, null) +on duplicate key update name = values(name), + url = values(url), + power_id = values(power_id), + parent_id = values(parent_id); + +insert into t_element(id, name, power_id, menu_id) +values (1010100, '公用', id, 1010000), + (101010100, '基础', id, 101010000), + (102010100, '基础', id, 102010000), + (103010100, '基础', id, 103010000) +on duplicate key update name = values(name), + power_id=values(power_id), + menu_id = values(menu_id); + +insert into t_operation(id, name, code, power_id, element_id, parent_id) +values (1010101, '查询当前用户信息', 'common:user:self', id, 1010100, null), + (101010101, '查询所有角色', 'system:role:get', id, 101010100, null), + (101010102, '添加角色', 'system:role:add', id, 101010100, null), + (101010103, '删除角色', 'system:role:delete', id, 101010100, null), + (101010104, '修改角色', 'system:role:modify', id, 101010100, null), + (102010101, '查询所有用户组', 'system:group:get', id, 102010100, null), + (102010102, '添加用户组', 'system:group:add', id, 102010100, null), + (102010103, '删除用户组', 'system:group:delete', id, 102010100, null), + (102010104, '修改用户组', 'system:group:modify', id, 102010100, null), + (103010101, '查看所有用户', 'system:user:get', id, 103010100, null), + (103010102, '查看单个用户', 'system:user:one', id, 103010100, null), + (103010103, '添加用户', 'system:user:add', id, 103010100, null), + (103010104, '删除用户', 'system:user:delete', id, 103010100, null), + (103010105, '修改用户', 'system:user:modify', id, 103010100, null) +on duplicate key update name=values(name), + code=values(code), + power_id=values(power_id), + element_id=values(element_id), + parent_id=values(parent_id); \ No newline at end of file diff --git a/src/main/resources/db/migration/V1_0_0_231023__Add_table_'t_power_type'.sql b/src/main/resources/db/migration/V1_0_0_231023__Add_table_'t_power_type'.sql new file mode 100644 index 0000000..2096872 --- /dev/null +++ b/src/main/resources/db/migration/V1_0_0_231023__Add_table_'t_power_type'.sql @@ -0,0 +1,7 @@ +drop table if exists t_power_type; + +create table if not exists t_power_type +( + id bigint not null primary key, + name varchar(50) not null comment '权限类型名' +) comment '权限类型'; \ No newline at end of file diff --git a/src/main/resources/db/migration/V1_0_0_231024__Add_table_'t_power'.sql b/src/main/resources/db/migration/V1_0_0_231024__Add_table_'t_power'.sql new file mode 100644 index 0000000..bd32054 --- /dev/null +++ b/src/main/resources/db/migration/V1_0_0_231024__Add_table_'t_power'.sql @@ -0,0 +1,7 @@ +drop table if exists t_power; + +create table if not exists t_power +( + `id` bigint not null primary key, + `type_id` bigint not null comment '权限类型' +) comment '权限'; \ No newline at end of file diff --git a/src/main/resources/db/migration/V1_0_0_231025__Add_table_'t_menu'.sql b/src/main/resources/db/migration/V1_0_0_231025__Add_table_'t_menu'.sql new file mode 100644 index 0000000..d85e070 --- /dev/null +++ b/src/main/resources/db/migration/V1_0_0_231025__Add_table_'t_menu'.sql @@ -0,0 +1,10 @@ +drop table if exists t_menu; + +create table if not exists t_menu +( + `id` bigint not null primary key, + `name` varchar(30) not null comment ' 菜单名', + `url` varchar(100) null comment 'URL', + `power_id` bigint not null comment '权限ID', + `parent_id` bigint null comment '父ID' +) comment '菜单'; \ No newline at end of file diff --git a/src/main/resources/db/migration/V1_0_0_231026__Add_table_'t_element'.sql b/src/main/resources/db/migration/V1_0_0_231026__Add_table_'t_element'.sql new file mode 100644 index 0000000..1175c69 --- /dev/null +++ b/src/main/resources/db/migration/V1_0_0_231026__Add_table_'t_element'.sql @@ -0,0 +1,9 @@ +drop table if exists t_element; + +create table if not exists t_element +( + `id` bigint not null primary key, + `name` varchar(100) not null comment '元素名', + `power_id` bigint not null comment '权限ID', + `menu_id` bigint not null comment '菜单ID' +) comment '页面元素'; \ No newline at end of file diff --git a/src/main/resources/db/migration/V1_0_0_231027__Add_table_'t_operation'.sql b/src/main/resources/db/migration/V1_0_0_231027__Add_table_'t_operation'.sql new file mode 100644 index 0000000..dc73326 --- /dev/null +++ b/src/main/resources/db/migration/V1_0_0_231027__Add_table_'t_operation'.sql @@ -0,0 +1,11 @@ +drop table if exists t_operation; + +create table if not exists t_operation +( + `id` bigint not null primary key, + `name` varchar(50) not null comment '功能名', + `code` varchar(50) null comment '功能编码', + `power_id` bigint not null comment '权限ID', + `parent_id` bigint null comment '父ID', + `element_id` bigint not null comment '页面元素ID' +) comment '功能'; \ No newline at end of file