优化站内信模块

This commit is contained in:
2026-06-17 23:07:39 +08:00
parent d3886e2475
commit 22e0e75c35
25 changed files with 2538 additions and 39 deletions
+12
View File
@@ -0,0 +1,12 @@
-- 升级已有的 yz_system_reminderlist 表,添加 batch_id 以及发送目标相关字段
ALTER TABLE `yz_system_reminderlist`
ADD COLUMN `batch_id` varchar(64) NOT NULL DEFAULT '' COMMENT '批次号/分组ID' AFTER `delete_time`,
ADD COLUMN `target_type` varchar(32) NOT NULL DEFAULT '' COMMENT '发送目标类型: platform, tenant_all, role, tenant' AFTER `batch_id`,
ADD COLUMN `target_role_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '目标角色ID' AFTER `target_type`,
ADD COLUMN `target_tenant_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '目标租户ID' AFTER `target_role_id`,
ADD INDEX `idx_batch` (`batch_id`);
-- 初始化已有记录的 batch_id (如果存在空值,使用 create_time 和 sender_id 进行分组初始化)
UPDATE `yz_system_reminderlist`
SET `batch_id` = CONCAT(UNIX_TIMESTAMP(COALESCE(`create_time`, NOW())), '_', `sender_id`)
WHERE `batch_id` = '' OR `batch_id` IS NULL;
+36
View File
@@ -0,0 +1,36 @@
-- 站内信配置表
CREATE TABLE IF NOT EXISTS `yz_system_sitereminder` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`retention_days` int(11) NOT NULL DEFAULT '30' COMMENT '消息保留天数',
`auto_read` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否自动标记已读: 0-否, 1-是',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='站内信配置表';
-- 默认插入一条配置数据
INSERT INTO `yz_system_sitereminder` (`id`, `retention_days`, `auto_read`, `create_time`, `update_time`)
VALUES (1, 30, 0, NOW(), NOW())
ON DUPLICATE KEY UPDATE `update_time` = NOW();
-- 站内信消息列表表
CREATE TABLE IF NOT EXISTS `yz_system_reminderlist` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`title` varchar(255) NOT NULL COMMENT '标题',
`content` text NOT NULL COMMENT '内容',
`sender_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '发送者ID (0为系统)',
`sender_type` varchar(32) NOT NULL DEFAULT 'system' COMMENT '发送者类型: system, platform, tenant',
`receiver_id` bigint(20) unsigned NOT NULL COMMENT '接收者ID',
`receiver_type` varchar(32) NOT NULL DEFAULT 'receiver' COMMENT '接收者类型: platform, tenant',
`is_read` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否已读: 0-未读, 1-已读',
`read_time` datetime DEFAULT NULL COMMENT '已读时间',
`create_time` datetime DEFAULT NULL COMMENT '创建时间/发送时间',
`delete_time` datetime DEFAULT NULL COMMENT '删除时间',
`batch_id` varchar(64) NOT NULL DEFAULT '' COMMENT '批次号/分组ID',
`target_type` varchar(32) NOT NULL DEFAULT '' COMMENT '发送目标类型: platform, tenant_all, role, tenant',
`target_role_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '目标角色ID',
`target_tenant_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '目标租户ID',
PRIMARY KEY (`id`),
KEY `idx_receiver` (`receiver_type`, `receiver_id`, `is_read`),
KEY `idx_batch` (`batch_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='站内信消息列表表';