权限管理接口实现
This commit is contained in:
@@ -2,115 +2,20 @@
|
||||
-- region 填充数据
|
||||
-- ====================
|
||||
|
||||
insert into client
|
||||
(client_id, client_secret, redirect_uri, spec, name, type)
|
||||
insert into client (type, spec, name, client_id, client_secret, redirect_uri) values (1, 3, 'web', 'web', '$2a$10$Ss12mXQgpYyo1CKIZ3URouDm.Lc2KcYJzsvEK2PTIXlv6fHQht45a', '');
|
||||
insert into client (type, spec, name, client_id, client_secret, redirect_uri) values (1, 3, 'admin', 'admin', '$2a$10$dlfvX5Uf3iVsUWgwlb0Wt.oYsw/OEXgS.Aior3yoT63Ju7ZSsJr/2', '');
|
||||
|
||||
insert into product (code, name, description) values ('dynamic-short', '短效动态', '短效动态');
|
||||
insert into product (code, name, description) values ('dynamic-long', '长效动态', '长效动态');
|
||||
insert into product (code, name, description) values ('static', '长效静态', '长效静态');
|
||||
|
||||
delete from permission where true;
|
||||
insert into permission
|
||||
(name, description)
|
||||
values
|
||||
('web', '$2a$10$Ss12mXQgpYyo1CKIZ3URouDm.Lc2KcYJzsvEK2PTIXlv6fHQht45a', '', 3, 'web', 1);
|
||||
|
||||
with pid as (
|
||||
insert into app.public.product
|
||||
(code, name, description)
|
||||
values
|
||||
('dynamic-short', '短效动态', '短效动态')
|
||||
returning id
|
||||
)
|
||||
insert into app.public.product_sku
|
||||
(product_id, code, name, price, discount)
|
||||
select pid.id, 'mode=quota,live=3,expire=0', '短效动态包量 3 分钟', 50, 1 from pid
|
||||
union all select pid.id, 'mode=quota,live=5,expire=0', '短效动态包量 5 分钟', 100, 1 from pid
|
||||
union all select pid.id, 'mode=quota,live=10,expire=0', '短效动态包量 10 分钟', 200, 1 from pid
|
||||
union all select pid.id, 'mode=quota,live=20,expire=0', '短效动态包量 20 分钟', 300, 1 from pid
|
||||
union all select pid.id, 'mode=quota,live=30,expire=0', '短效动态包量 30 分钟', 600, 1 from pid
|
||||
|
||||
union all select pid.id, 'mode=time,live=3,expire=7', '短效动态包时 7 天 3 分钟', 56, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=3,expire=15', '短效动态包时 15 天 3 分钟', 90, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=3,expire=30', '短效动态包时 30 天 3 分钟', 180, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=3,expire=90', '短效动态包时 90 天 3 分钟', 450, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=3,expire=180', '短效动态包时 180 天 3 分钟', 900, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=3,expire=365', '短效动态包时 365 天 3 分钟', 1642.5, 1 from pid
|
||||
|
||||
union all select pid.id, 'mode=time,live=5,expire=7', '短效动态包时 7 天 5 分钟', 56, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=5,expire=15', '短效动态包时 15 天 5 分钟', 90, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=5,expire=30', '短效动态包时 30 天 5 分钟', 180, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=5,expire=90', '短效动态包时 90 天 5 分钟', 450, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=5,expire=180', '短效动态包时 180 天 5 分钟', 900, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=5,expire=365', '短效动态包时 365 天 5 分钟', 1642.5, 1 from pid
|
||||
|
||||
union all select pid.id, 'mode=time,live=10,expire=7', '短效动态包时 7 天 10 分钟', 56, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=10,expire=15', '短效动态包时 15 天 10 分钟', 90, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=10,expire=30', '短效动态包时 30 天 10 分钟', 180, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=10,expire=90', '短效动态包时 90 天 10 分钟', 450, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=10,expire=180', '短效动态包时 180 天 10 分钟', 900, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=10,expire=365', '短效动态包时 365 天 10 分钟', 1642.5, 1 from pid
|
||||
|
||||
union all select pid.id, 'mode=time,live=20,expire=7', '短效动态包时 7 天 20 分钟', 56, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=20,expire=15', '短效动态包时 15 天 20 分钟', 90, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=20,expire=30', '短效动态包时 30 天 20 分钟', 180, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=20,expire=90', '短效动态包时 90 天 20 分钟', 450, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=20,expire=180', '短效动态包时 180 天 20 分钟', 900, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=20,expire=365', '短效动态包时 365 天 20 分钟', 1642.5, 1 from pid
|
||||
|
||||
union all select pid.id, 'mode=time,live=30,expire=7', '短效动态包时 7 天 30 分钟', 56, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=30,expire=15', '短效动态包时 15 天 30 分钟', 90, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=30,expire=30', '短效动态包时 30 天 30 分钟', 180, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=30,expire=90', '短效动态包时 90 天 30 分钟', 450, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=30,expire=180', '短效动态包时 180 天 30 分钟', 900, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=30,expire=365', '短效动态包时 365 天 30 分钟', 1642.5, 1 from pid
|
||||
('permission:read', '读取权限列表'),
|
||||
('permission:write', '写入权限'),
|
||||
('admin-role:read', '读取管理员角色列表'),
|
||||
('admin-role:write', '写入管理员角色')
|
||||
;
|
||||
|
||||
with pid as (
|
||||
insert into app.public.product
|
||||
(code, name, description)
|
||||
values
|
||||
('dynamic-long', '长效动态', '长效动态')
|
||||
returning id
|
||||
)
|
||||
insert into app.public.product_sku
|
||||
(product_id, code, name, price, discount)
|
||||
select pid.id, 'mode=quota,live=60,expire=0', '长效动态包量 60 分钟', 50, 1 from pid
|
||||
union all select pid.id, 'mode=quota,live=240,expire=0', '长效动态包量 240 分钟', 100, 1 from pid
|
||||
union all select pid.id, 'mode=quota,live=480,expire=0', '长效动态包量 480 分钟', 200, 1 from pid
|
||||
union all select pid.id, 'mode=quota,live=720,expire=0', '长效动态包量 720 分钟', 300, 1 from pid
|
||||
union all select pid.id, 'mode=quota,live=1440,expire=0', '长效动态包量 1440 分钟', 600, 1 from pid
|
||||
|
||||
union all select pid.id, 'mode=time,live=60,expire=7', '长效动态包时 7 天 60 分钟', 56, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=60,expire=15', '长效动态包时 15 天 60 分钟', 90, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=60,expire=30', '长效动态包时 30 天 60 分钟', 180, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=60,expire=90', '长效动态包时 90 天 60 分钟', 450, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=60,expire=180', '长效动态包时 180 天 60 分钟', 900, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=60,expire=365', '长效动态包时 365 天 60 分钟', 1642.5, 1 from pid
|
||||
|
||||
union all select pid.id, 'mode=time,live=240,expire=7', '长效动态包时 7 天 240 分钟', 56, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=240,expire=15', '长效动态包时 15 天 240 分钟', 90, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=240,expire=30', '长效动态包时 30 天 240 分钟', 180, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=240,expire=90', '长效动态包时 90 天 240 分钟', 450, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=240,expire=180', '长效动态包时 180 天 240 分钟', 900, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=240,expire=365', '长效动态包时 365 天 240 分钟', 1642.5, 1 from pid
|
||||
|
||||
union all select pid.id, 'mode=time,live=480,expire=7', '长效动态包时 7 天 480 分钟', 56, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=480,expire=15', '长效动态包时 15 天 480 分钟', 90, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=480,expire=30', '长效动态包时 30 天 480 分钟', 180, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=480,expire=90', '长效动态包时 90 天 480 分钟', 450, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=480,expire=180', '长效动态包时 180 天 480 分钟', 900, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=480,expire=365', '长效动态包时 365 天 480 分钟', 1642.5, 1 from pid
|
||||
|
||||
union all select pid.id, 'mode=time,live=720,expire=7', '长效动态包时 7 天 720 分钟', 56, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=720,expire=15', '长效动态包时 15 天 720 分钟', 90, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=720,expire=30', '长效动态包时 30 天 720 分钟', 180, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=720,expire=90', '长效动态包时 90 天 720 分钟', 450, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=720,expire=180', '长效动态包时 180 天 720 分钟', 900, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=720,expire=365', '长效动态包时 365 天 720 分钟', 1642.5, 1 from pid
|
||||
|
||||
union all select pid.id, 'mode=time,live=1440,expire=7', '长效动态包时 7 天 1440 分钟', 56, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=1440,expire=15', '长效动态包时 15 天 1440 分钟', 90, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=1440,expire=30', '长效动态包时 30 天 1440 分钟', 180, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=1440,expire=90', '长效动态包时 90 天 1440 分钟', 450, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=1440,expire=180', '长效动态包时 180 天 1440 分钟', 900, 1 from pid
|
||||
union all select pid.id, 'mode=time,live=1440,expire=365', '长效动态包时 365 天 1440 分钟', 1642.5, 1 from pid
|
||||
;
|
||||
|
||||
insert into app.public.product
|
||||
(code, name, description)
|
||||
values
|
||||
('static', '长效静态', '长效静态');
|
||||
-- endregion
|
||||
|
||||
@@ -227,8 +227,8 @@ create table admin_role (
|
||||
id int generated by default as identity primary key,
|
||||
name text not null,
|
||||
description text,
|
||||
active bool default true,
|
||||
sort int default 0,
|
||||
active bool not null default true,
|
||||
sort int not null default 0,
|
||||
created_at timestamptz default current_timestamp,
|
||||
updated_at timestamptz default current_timestamp,
|
||||
deleted_at timestamptz
|
||||
@@ -451,63 +451,63 @@ drop table if exists link_user_role cascade;
|
||||
create table link_user_role (
|
||||
id int generated by default as identity primary key,
|
||||
user_id int not null,
|
||||
role_id int not null
|
||||
user_role_id int not null
|
||||
);
|
||||
create index idx_link_user_role_user_id on link_user_role (user_id);
|
||||
create index idx_link_user_role_role_id on link_user_role (role_id);
|
||||
create index idx_link_user_role_role_id on link_user_role (user_role_id);
|
||||
|
||||
-- link_user_role表字段注释
|
||||
comment on table link_user_role is '用户角色关联表';
|
||||
comment on column link_user_role.id is '关联ID';
|
||||
comment on column link_user_role.user_id is '用户ID';
|
||||
comment on column link_user_role.role_id is '角色ID';
|
||||
comment on column link_user_role.user_role_id is '角色ID';
|
||||
|
||||
-- link_admin_role
|
||||
drop table if exists link_admin_role cascade;
|
||||
create table link_admin_role (
|
||||
id int generated by default as identity primary key,
|
||||
admin_id int not null,
|
||||
role_id int not null
|
||||
admin_role_id int not null
|
||||
);
|
||||
create index idx_link_admin_role_admin_id on link_admin_role (admin_id);
|
||||
create index idx_link_admin_role_role_id on link_admin_role (role_id);
|
||||
create index idx_link_admin_role_role_id on link_admin_role (admin_role_id);
|
||||
|
||||
-- link_admin_role表字段注释
|
||||
comment on table link_admin_role is '管理员角色关联表';
|
||||
comment on column link_admin_role.id is '关联ID';
|
||||
comment on column link_admin_role.admin_id is '管理员ID';
|
||||
comment on column link_admin_role.role_id is '角色ID';
|
||||
comment on column link_admin_role.admin_role_id is '角色ID';
|
||||
|
||||
-- link_user_role_permission
|
||||
drop table if exists link_user_role_permission cascade;
|
||||
create table link_user_role_permission (
|
||||
id int generated by default as identity primary key,
|
||||
role_id int not null,
|
||||
user_role_id int not null,
|
||||
permission_id int not null
|
||||
);
|
||||
create index idx_link_user_role_permission_role_id on link_user_role_permission (role_id);
|
||||
create index idx_link_user_role_permission_role_id on link_user_role_permission (user_role_id);
|
||||
create index idx_link_user_role_permission_permission_id on link_user_role_permission (permission_id);
|
||||
|
||||
-- link_user_role_permission表字段注释
|
||||
comment on table link_user_role_permission is '用户角色权限关联表';
|
||||
comment on column link_user_role_permission.id is '关联ID';
|
||||
comment on column link_user_role_permission.role_id is '角色ID';
|
||||
comment on column link_user_role_permission.user_role_id is '角色ID';
|
||||
comment on column link_user_role_permission.permission_id is '权限ID';
|
||||
|
||||
-- link_admin_role_permission
|
||||
drop table if exists link_admin_role_permission cascade;
|
||||
create table link_admin_role_permission (
|
||||
id int generated by default as identity primary key,
|
||||
role_id int not null,
|
||||
admin_role_id int not null,
|
||||
permission_id int not null
|
||||
);
|
||||
create index idx_link_admin_role_permission_role_id on link_admin_role_permission (role_id);
|
||||
create index idx_link_admin_role_permission_role_id on link_admin_role_permission (admin_role_id);
|
||||
create index idx_link_admin_role_permission_permission_id on link_admin_role_permission (permission_id);
|
||||
|
||||
-- link_admin_role_permission表字段注释
|
||||
comment on table link_admin_role_permission is '管理员角色权限关联表';
|
||||
comment on column link_admin_role_permission.id is '关联ID';
|
||||
comment on column link_admin_role_permission.role_id is '角色ID';
|
||||
comment on column link_admin_role_permission.admin_role_id is '角色ID';
|
||||
comment on column link_admin_role_permission.permission_id is '权限ID';
|
||||
|
||||
-- link_client_permission
|
||||
@@ -1034,23 +1034,23 @@ alter table permission
|
||||
alter table link_user_role
|
||||
add constraint fk_link_user_role_user_id foreign key (user_id) references "user" (id) on delete cascade;
|
||||
alter table link_user_role
|
||||
add constraint fk_link_user_role_role_id foreign key (role_id) references user_role (id) on delete cascade;
|
||||
add constraint fk_link_user_role_role_id foreign key (user_role_id) references user_role (id) on delete cascade;
|
||||
|
||||
-- link_admin_role表外键
|
||||
alter table link_admin_role
|
||||
add constraint fk_link_admin_role_admin_id foreign key (admin_id) references admin (id) on delete cascade;
|
||||
alter table link_admin_role
|
||||
add constraint fk_link_admin_role_role_id foreign key (role_id) references admin_role (id) on delete cascade;
|
||||
add constraint fk_link_admin_role_role_id foreign key (admin_role_id) references admin_role (id) on delete cascade;
|
||||
|
||||
-- link_user_role_permission表外键
|
||||
alter table link_user_role_permission
|
||||
add constraint fk_link_user_role_permission_role_id foreign key (role_id) references user_role (id) on delete cascade;
|
||||
add constraint fk_link_user_role_permission_role_id foreign key (user_role_id) references user_role (id) on delete cascade;
|
||||
alter table link_user_role_permission
|
||||
add constraint fk_link_user_role_permission_permission_id foreign key (permission_id) references permission (id) on delete cascade;
|
||||
|
||||
-- link_admin_role_permission表外键
|
||||
alter table link_admin_role_permission
|
||||
add constraint fk_link_admin_role_permission_role_id foreign key (role_id) references admin_role (id) on delete cascade;
|
||||
add constraint fk_link_admin_role_permission_role_id foreign key (admin_role_id) references admin_role (id) on delete cascade;
|
||||
alter table link_admin_role_permission
|
||||
add constraint fk_link_admin_role_permission_permission_id foreign key (permission_id) references permission (id) on delete cascade;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user