实现文章与分组管理
This commit is contained in:
@@ -128,7 +128,9 @@ insert into permission (name, description, sort) values
|
||||
('bill', '账单', 13),
|
||||
('balance_activity', '余额变动', 14),
|
||||
('proxy', '代理', 15),
|
||||
('coupon_user', '已发放优惠券', 16);
|
||||
('coupon_user', '已发放优惠券', 16),
|
||||
('article', '文档', 17),
|
||||
('article_group', '文档分组', 18);
|
||||
|
||||
-- --------------------------
|
||||
-- level 2
|
||||
@@ -215,6 +217,16 @@ insert into permission (parent_id, name, description, sort) values
|
||||
((select id from permission where name = 'coupon_user' and deleted_at is null), 'coupon_user:read', '读取已发放优惠券列表', 1),
|
||||
((select id from permission where name = 'coupon_user' and deleted_at is null), 'coupon_user:write', '编辑已发放优惠券', 2);
|
||||
|
||||
-- article 子权限
|
||||
insert into permission (parent_id, name, description, sort) values
|
||||
((select id from permission where name = 'article' and deleted_at is null), 'article:read', '读取文档列表', 1),
|
||||
((select id from permission where name = 'article' and deleted_at is null), 'article:write', '编辑文档', 2);
|
||||
|
||||
-- article_group 子权限
|
||||
insert into permission (parent_id, name, description, sort) values
|
||||
((select id from permission where name = 'article_group' and deleted_at is null), 'article_group:read', '读取文档分组列表', 1),
|
||||
((select id from permission where name = 'article_group' and deleted_at is null), 'article_group:write', '编辑文档分组', 2);
|
||||
|
||||
-- --------------------------
|
||||
-- level 3
|
||||
-- --------------------------
|
||||
|
||||
@@ -143,6 +143,62 @@ comment on column announcement.created_at is '创建时间';
|
||||
comment on column announcement.updated_at is '更新时间';
|
||||
comment on column announcement.deleted_at is '删除时间';
|
||||
|
||||
-- article_group
|
||||
drop table if exists article_group cascade;
|
||||
create table article_group (
|
||||
id int generated by default as identity primary key,
|
||||
name text not null,
|
||||
code text not null,
|
||||
sort int not null default 0,
|
||||
status int not null default 1,
|
||||
created_at timestamptz default current_timestamp,
|
||||
updated_at timestamptz default current_timestamp,
|
||||
deleted_at timestamptz
|
||||
);
|
||||
create unique index udx_article_group_code on article_group (code) where deleted_at is null;
|
||||
create index idx_article_group_status on article_group (status) where deleted_at is null;
|
||||
create index idx_article_group_sort on article_group (sort) where deleted_at is null;
|
||||
|
||||
-- article_group表字段注释
|
||||
comment on table article_group is '文章分组表';
|
||||
comment on column article_group.id is '分组ID';
|
||||
comment on column article_group.name is '分组名称';
|
||||
comment on column article_group.code is '分组编码';
|
||||
comment on column article_group.sort is '分组排序';
|
||||
comment on column article_group.status is '分组状态:0-禁用,1-正常';
|
||||
comment on column article_group.created_at is '创建时间';
|
||||
comment on column article_group.updated_at is '更新时间';
|
||||
comment on column article_group.deleted_at is '删除时间';
|
||||
|
||||
-- article
|
||||
drop table if exists article cascade;
|
||||
create table article (
|
||||
id int generated by default as identity primary key,
|
||||
group_id int not null,
|
||||
title text not null,
|
||||
content text,
|
||||
sort int not null default 0,
|
||||
status int not null default 1,
|
||||
created_at timestamptz default current_timestamp,
|
||||
updated_at timestamptz default current_timestamp,
|
||||
deleted_at timestamptz
|
||||
);
|
||||
create index idx_article_group_id on article (group_id) where deleted_at is null;
|
||||
create index idx_article_status on article (status) where deleted_at is null;
|
||||
create index idx_article_sort on article (sort) where deleted_at is null;
|
||||
|
||||
-- article表字段注释
|
||||
comment on table article is '文章表';
|
||||
comment on column article.id is '文章ID';
|
||||
comment on column article.group_id is '分组ID';
|
||||
comment on column article.title is '文章标题';
|
||||
comment on column article.content is '文章内容';
|
||||
comment on column article.sort is '文章排序';
|
||||
comment on column article.status is '文章状态:0-禁用,1-正常';
|
||||
comment on column article.created_at is '创建时间';
|
||||
comment on column article.updated_at is '更新时间';
|
||||
comment on column article.deleted_at is '删除时间';
|
||||
|
||||
-- inquiry
|
||||
drop table if exists inquiry cascade;
|
||||
create table inquiry (
|
||||
@@ -1228,6 +1284,10 @@ alter table coupon_user
|
||||
alter table coupon_user
|
||||
add constraint fk_coupon_user_coupon_id foreign key (coupon_id) references coupon (id) on delete cascade;
|
||||
|
||||
-- article表外键
|
||||
alter table article
|
||||
add constraint fk_article_group_id foreign key (group_id) references article_group (id) on delete restrict;
|
||||
|
||||
-- product_sku表外键
|
||||
alter table product_sku
|
||||
add constraint fk_product_sku_product_id foreign key (product_id) references product (id) on delete cascade;
|
||||
|
||||
Reference in New Issue
Block a user