1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-04 22:41:24 +08:00

Added role management

This commit is contained in:
2023-05-15 08:32:16 +08:00
parent e491e21f88
commit 292ea5dad6
33 changed files with 752 additions and 55 deletions

View File

@@ -1,4 +1,4 @@
SET FOREIGN_KEY_CHECKS=0;
SET FOREIGN_KEY_CHECKS = 0;
truncate t_menu;
truncate t_element;
@@ -7,54 +7,99 @@ truncate t_operation_log;
truncate t_operation;
truncate t_power;
truncate t_power_type;
truncate t_role;
truncate t_power_role;
insert into t_power_type (id, name)
values (1, 'operation'),
(2, 'menu'),
(3, 'element'),
(4, 'file');
values (1, 'menu'),
(2, 'element'),
(3, 'operation');
begin;
insert into t_power (type_id)
values (1);
insert into t_operation (name, code, power_id, parent_id)
values ('Select All Power Type', 'system:power_type:all', last_insert_id(), null);
insert into t_menu (id, name, url, power_id, parent_id)
VALUES (1, '公用', '/', last_insert_id(), null);
commit;
begin;
insert into t_power (type_id)
values (1);
insert into t_operation (name, code, power_id, parent_id)
values ('Select All Power', 'system:power:all', last_insert_id(), null);
values (2);
insert into t_element(id, name, power_id, menu_id)
VALUES (1, '公用', last_insert_id(), 1);
commit;
begin;
insert into t_power(type_id)
values (3);
insert into t_operation(name, code, power_id, element_id, parent_id)
VALUES ('查询当前用户权限', 'common:power:self', last_insert_id(), 1, null);
commit;
begin;
insert into t_power(type_id)
values (3);
insert into t_operation(name, code, power_id, element_id, parent_id)
VALUES ('查询当前用户信息', 'common:info:self', last_insert_id(), 1, null);
commit;
begin;
insert into t_power (type_id)
values (1);
insert into t_operation (name, code, power_id, parent_id)
values ('Select All User', 'system:operation:all', last_insert_id(), null);
insert into t_menu (id, name, url, power_id, parent_id)
VALUES (2, '角色管理', '/system/role', last_insert_id(), null);
commit;
begin;
insert into t_power (type_id)
values (1);
insert into t_operation (name, code, power_id, parent_id)
values ('Select All User', 'system:menu:all', last_insert_id(), null);
values (2);
insert into t_element (id, name, power_id, menu_id)
VALUES (2, '角色列表', last_insert_id(), 2);
commit;
begin;
insert into t_power (type_id)
values (1);
insert into t_operation (name, code, power_id, parent_id)
values ('Select All User', 'system:element:all', last_insert_id(), null);
values (3);
insert into t_operation (name, code, power_id, element_id, parent_id)
VALUES ('查询所有权限', 'system:power:all', last_insert_id(), 2, null);
commit;
begin;
insert into t_power (type_id)
values (1);
insert into t_operation (name, code, power_id, parent_id)
values ('Select All User', 'system:file:all', last_insert_id(), null);
values (3);
insert into t_operation (name, code, power_id, element_id, parent_id)
VALUES ('查询所有角色', 'system:role:all', last_insert_id(), 2, null);
commit;
SET FOREIGN_KEY_CHECKS=1;
begin;
insert into t_power (type_id)
values (3);
insert into t_operation (name, code, power_id, element_id, parent_id)
VALUES ('查询所有用户', 'system:user:all', last_insert_id(), 2, null);
commit;
insert into t_role (id, name)
values (1655784840189972481, '员工'),
(1655784928056467457, '组长'),
(1655785102375940097, '主管'),
(1655785102375940098, '总管');
insert into t_power_role(id, power_id, role_id)
VALUES (1656219345971326978, 1, 1655784840189972481),
(1656219345971326979, 2, 1655784840189972481),
(1656219345971326980, 3, 1655784840189972481),
(1656219345971326981, 4, 1655784840189972481),
(1656219345971326982, 5, 1655785102375940098),
(1656219345971326983, 6, 1655785102375940098),
(1656219345971326984, 7, 1655785102375940098),
(1656219345971326985, 8, 1655785102375940098),
(1656219345971326986, 9, 1655785102375940098);
select * from t_role
left join t_power_role tpr on t_role.id = tpr.role_id
left join t_power tp on tp.id = tpr.power_id
left join t_menu tm on tp.id = tm.power_id
left join t_element te on tp.id = te.power_id
left join t_operation t on tp.id = t.power_id;
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -52,7 +52,9 @@ create table `t_element`
`id` bigint not null primary key auto_increment,
`name` varchar(100) not null comment '元素名',
`power_id` bigint not null comment '权限ID',
constraint t_element_power_id_fk foreign key (power_id) references t_power (id)
`menu_id` bigint not null comment '菜单ID',
constraint t_element_power_id_fk foreign key (power_id) references t_power (id),
constraint t_element_menu_id_fk foreign key (menu_id) references t_menu (id)
) comment '页面元素';
create table `t_file`
@@ -66,12 +68,14 @@ create table `t_file`
create table `t_operation`
(
`id` bigint not null primary key auto_increment,
`name` varchar(50) not null comment '功能名',
`code` varchar(50) null comment '功能编码',
`power_id` bigint not null comment '权限ID',
`parent_id` bigint null comment '父ID',
constraint t_operation_power_id_fk foreign key (power_id) references t_power (id)
`id` bigint not null primary key auto_increment,
`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',
constraint t_operation_power_id_fk foreign key (power_id) references t_power (id),
constraint t_operation_element_id_fk foreign key (element_id) references t_element (id)
) comment '功能';
create table `t_department`