Files
yichayilu_boot/doc/sql/pending/20260209_increase.sql
RayL 7bbb0c1026 feat:
1. notice module
2026-02-12 09:50:12 +08:00

78 lines
5.3 KiB
SQL

DROP TABLE IF EXISTS user_notice;
CREATE TABLE user_notice
(
id int8 NOT NULL PRIMARY KEY, -- 主键
user_id int8 NOT NULL, -- 用户id
notice_type int4 DEFAULT 0 NOT NULL, -- 通知类型 0-系统通知 1-app通知 2-market通知
module_type int4 NULL, -- 业务模块
has_read int4 DEFAULT 0 NOT NULL, -- 是否已读 0-否 1-是
title VARCHAR(100) NULL, -- 标题
content TEXT NULL, -- 内容
remarks varchar(200) NULL, -- 备注
create_user int8 NULL, -- 创建人
create_dept int8 NULL, -- 创建部门
create_time timestamp(6) NULL, -- 创建时间
update_user int8 NULL, -- 修改人
update_time timestamp(6) NULL, -- 修改时间
status int4 NULL, -- 状态
is_deleted int4 DEFAULT 0 NULL -- 是否已删除
);
COMMENT ON TABLE user_notice IS '用户通知';
COMMENT ON COLUMN user_notice.id IS '主键';
COMMENT ON COLUMN user_notice.user_id IS '用户id';
COMMENT ON COLUMN user_notice.notice_type IS '通知类型 0-系统通知 1-app通知 2-market通知';
COMMENT ON COLUMN user_notice.module_type IS '业务模块类型';
COMMENT ON COLUMN user_notice.has_read IS '是否已读 0-否 1-是';
COMMENT ON COLUMN user_notice.title IS '标题';
COMMENT ON COLUMN user_notice.content IS '内容';
COMMENT ON COLUMN user_notice.remarks IS '备注';
COMMENT ON COLUMN user_notice.create_user IS '创建人';
COMMENT ON COLUMN user_notice.create_dept IS '创建部门';
COMMENT ON COLUMN user_notice.create_time IS '创建时间';
COMMENT ON COLUMN user_notice.update_user IS '修改人';
COMMENT ON COLUMN user_notice.update_time IS '修改时间';
COMMENT ON COLUMN user_notice.status IS '状态';
COMMENT ON COLUMN user_notice.is_deleted IS '是否已删除';
CREATE INDEX CONCURRENTLY idx_user_notice_opt ON user_notice (user_id, has_read ASC, create_time DESC, notice_type) WHERE is_deleted = 0;
CREATE INDEX CONCURRENTLY idx_user_notice_count ON user_notice (user_id, notice_type, has_read) WHERE is_deleted = 0;
---- 后台页面菜单
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, component,
remark, is_deleted)
VALUES (2020763647899787265, 1123598815738675201, 'userNotice', '用户通知', 'menu', '/common/commonUserNotice', null, 1, 1,
0, 1, null, null, 0);
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, component,
remark, is_deleted)
VALUES (2020763647899787266, 2020763647899787265, 'userNotice_add', '新增', 'add', '/common/commonUserNotice/add', 'plus',
1, 2, 1, 1, null, null, 0);
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, component,
remark, is_deleted)
VALUES (2020763647899787267, 2020763647899787265, 'userNotice_edit', '修改', 'edit', '/common/commonUserNotice/edit',
'form', 2, 2, 2, 1, null, null, 0);
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, component,
remark, is_deleted)
VALUES (2020763647899787268, 2020763647899787265, 'userNotice_delete', '删除', 'delete',
'/api/common/commonUserNotice/remove', 'delete', 3, 2, 3, 1, null, null, 0);
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, component,
remark, is_deleted)
VALUES (2020763647899787269, 2020763647899787265, 'userNotice_view', '查看', 'view', '/common/commonUserNotice/view',
'file-text', 4, 2, 2, 1, null, null, 0);
--- 后台系统参数-字典 通知类型 0-全局通知 1-APP系统通知 2-Market系统通知 3-APP用户通知 4-Market用户通知
INSERT INTO blade_dict (id, parent_id, code, dict_key, dict_value, sort, remark, is_sealed, status, is_deleted)
VALUES (2020766458167353346, 0, 'notice_type', '-1', '通知类型', 28, '', 0, 1, 0);
INSERT INTO blade_dict (id, parent_id, code, dict_key, dict_value, sort, remark, is_sealed, status, is_deleted)
VALUES (2020766503033823233, 2020766458167353346, 'notice_type', '0', '全局通知', 0, '', 0, 1, 0);
INSERT INTO blade_dict (id, parent_id, code, dict_key, dict_value, sort, remark, is_sealed, status, is_deleted)
VALUES (2020766543760515074, 2020766458167353346, 'notice_type', '1', 'APP系统通知', 1, '', 0, 1, 0);
INSERT INTO blade_dict (id, parent_id, code, dict_key, dict_value, sort, remark, is_sealed, status, is_deleted)
VALUES (2020766604569534466, 2020766458167353346, 'notice_type', '2', 'Market系统通知', 2, '', 0, 1, 0);
INSERT INTO blade_dict (id, parent_id, code, dict_key, dict_value, sort, remark, is_sealed, status, is_deleted)
VALUES (2020766604569534467, 2020766458167353346, 'notice_type', '3', 'APP用户通知', 2, '', 0, 1, 0);
INSERT INTO blade_dict (id, parent_id, code, dict_key, dict_value, sort, remark, is_sealed, status, is_deleted)
VALUES (2020766604569534468, 2020766458167353346, 'notice_type', '3', 'Market用户通知', 2, '', 0, 1, 0);