From f06e895eb19fb8a4e9eee1be384f1697b88a0fe1 Mon Sep 17 00:00:00 2001 From: wangzhiwei Date: Mon, 25 May 2026 10:01:31 +0800 Subject: [PATCH] =?UTF-8?q?refactor(notification):=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E8=A1=A8=E7=BB=93=E6=9E=84=EF=BC=8C=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E8=87=AA=E5=A2=9E=E4=B8=BB=E9=94=AE=EF=BC=8C=E6=89=8B?= =?UTF-8?q?=E5=8A=A8=E7=94=9F=E6=88=90ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/create_edu_tables.sql | 27 +++++++++---------- .../impl/SysNotificationServiceImpl.java | 1 + .../mapper/SysNotificationMapper.xml | 6 ++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/db/create_edu_tables.sql b/db/create_edu_tables.sql index 6c3f142..a64c06f 100644 --- a/db/create_edu_tables.sql +++ b/db/create_edu_tables.sql @@ -63,21 +63,20 @@ CREATE TABLE `edu_teacher` ( -- 4. 通知表 DROP TABLE IF EXISTS `sys_notification`; CREATE TABLE `sys_notification` ( - `id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID', - `school_id` BIGINT(20) NOT NULL COMMENT '学校ID(数据隔离)', - `user_id` BIGINT(20) NOT NULL COMMENT '用户ID', - `title` VARCHAR(100) NOT NULL COMMENT '通知标题', - `content` TEXT NOT NULL COMMENT '通知内容', - `type` TINYINT(1) DEFAULT '1' COMMENT '通知类型:1-系统通知,2-作业通知,3-考试通知,4-考勤通知,5-用户通知,6-课程通知', - `is_read` TINYINT(1) DEFAULT '0' COMMENT '是否已读:0-未读,1-已读', - `sender_id` BIGINT(20) DEFAULT NULL COMMENT '发送者用户ID', - `sender_name` VARCHAR(100) DEFAULT NULL COMMENT '发送者姓名', - `target_type` TINYINT(1) DEFAULT '1' COMMENT '目标类型:1-单个用户,2-角色,3-课程', - `create_time` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - PRIMARY KEY (`id`), - KEY `idx_school_id` (`school_id`), + `id` BIGINT NOT NULL COMMENT '主键ID', + `school_id` BIGINT DEFAULT NULL COMMENT '学校ID', + `user_id` BIGINT DEFAULT NULL COMMENT '接收用户ID', + `title` VARCHAR(255) DEFAULT NULL COMMENT '通知标题', + `content` TEXT COMMENT '通知内容', + `type` TINYINT DEFAULT NULL COMMENT '通知类型', + `is_read` TINYINT DEFAULT '0' COMMENT '是否已读 0未读 1已读', + `sender_id` BIGINT DEFAULT NULL COMMENT '发送人ID', + `sender_name` VARCHAR(64) DEFAULT NULL COMMENT '发送人姓名', + `target_type` TINYINT DEFAULT NULL COMMENT '目标类型', + `create_time` DATETIME DEFAULT NULL COMMENT '创建时间', + PRIMARY KEY (`id`) USING BTREE, KEY `idx_user_id` (`user_id`), - KEY `idx_is_read` (`is_read`) + KEY `idx_school_id` (`school_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='通知表'; -- 5. 课程表 diff --git a/src/main/java/art/kexue/sxwz/service/impl/SysNotificationServiceImpl.java b/src/main/java/art/kexue/sxwz/service/impl/SysNotificationServiceImpl.java index 8f5fc81..d672f54 100644 --- a/src/main/java/art/kexue/sxwz/service/impl/SysNotificationServiceImpl.java +++ b/src/main/java/art/kexue/sxwz/service/impl/SysNotificationServiceImpl.java @@ -219,6 +219,7 @@ public class SysNotificationServiceImpl implements SysNotificationService { String content, Integer type, Long senderId, String senderName, Integer targetType) { SysNotification notification = new SysNotification(); + notification.setId(System.currentTimeMillis()); notification.setSchoolId(schoolId); notification.setUserId(userId); notification.setTitle(title); diff --git a/src/main/resources/mapper/SysNotificationMapper.xml b/src/main/resources/mapper/SysNotificationMapper.xml index ef16690..425412d 100644 --- a/src/main/resources/mapper/SysNotificationMapper.xml +++ b/src/main/resources/mapper/SysNotificationMapper.xml @@ -121,11 +121,11 @@ WHERE user_id = #{userId} AND school_id = #{schoolId} AND is_read = 0 - - INSERT INTO sys_notification (school_id, user_id, title, content, type, is_read, sender_id, sender_name, target_type, create_time) + + INSERT INTO sys_notification (id, school_id, user_id, title, content, type, is_read, sender_id, sender_name, target_type, create_time) VALUES - (#{item.schoolId}, #{item.userId}, #{item.title}, #{item.content}, #{item.type}, #{item.isRead}, #{item.senderId}, #{item.senderName}, #{item.targetType}, #{item.createTime}) + (#{item.id}, #{item.schoolId}, #{item.userId}, #{item.title}, #{item.content}, #{item.type}, #{item.isRead}, #{item.senderId}, #{item.senderName}, #{item.targetType}, #{item.createTime})