refactor(notification): 更新通知表结构,移除自增主键,手动生成ID
This commit is contained in:
parent
e22784fe2c
commit
f06e895eb1
@ -63,21 +63,20 @@ CREATE TABLE `edu_teacher` (
|
|||||||
-- 4. 通知表
|
-- 4. 通知表
|
||||||
DROP TABLE IF EXISTS `sys_notification`;
|
DROP TABLE IF EXISTS `sys_notification`;
|
||||||
CREATE TABLE `sys_notification` (
|
CREATE TABLE `sys_notification` (
|
||||||
`id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
`id` BIGINT NOT NULL COMMENT '主键ID',
|
||||||
`school_id` BIGINT(20) NOT NULL COMMENT '学校ID(数据隔离)',
|
`school_id` BIGINT DEFAULT NULL COMMENT '学校ID',
|
||||||
`user_id` BIGINT(20) NOT NULL COMMENT '用户ID',
|
`user_id` BIGINT DEFAULT NULL COMMENT '接收用户ID',
|
||||||
`title` VARCHAR(100) NOT NULL COMMENT '通知标题',
|
`title` VARCHAR(255) DEFAULT NULL COMMENT '通知标题',
|
||||||
`content` TEXT NOT NULL COMMENT '通知内容',
|
`content` TEXT COMMENT '通知内容',
|
||||||
`type` TINYINT(1) DEFAULT '1' COMMENT '通知类型:1-系统通知,2-作业通知,3-考试通知,4-考勤通知,5-用户通知,6-课程通知',
|
`type` TINYINT DEFAULT NULL COMMENT '通知类型',
|
||||||
`is_read` TINYINT(1) DEFAULT '0' COMMENT '是否已读:0-未读,1-已读',
|
`is_read` TINYINT DEFAULT '0' COMMENT '是否已读 0未读 1已读',
|
||||||
`sender_id` BIGINT(20) DEFAULT NULL COMMENT '发送者用户ID',
|
`sender_id` BIGINT DEFAULT NULL COMMENT '发送人ID',
|
||||||
`sender_name` VARCHAR(100) DEFAULT NULL COMMENT '发送者姓名',
|
`sender_name` VARCHAR(64) DEFAULT NULL COMMENT '发送人姓名',
|
||||||
`target_type` TINYINT(1) DEFAULT '1' COMMENT '目标类型:1-单个用户,2-角色,3-课程',
|
`target_type` TINYINT DEFAULT NULL COMMENT '目标类型',
|
||||||
`create_time` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
`create_time` DATETIME DEFAULT NULL COMMENT '创建时间',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
KEY `idx_school_id` (`school_id`),
|
|
||||||
KEY `idx_user_id` (`user_id`),
|
KEY `idx_user_id` (`user_id`),
|
||||||
KEY `idx_is_read` (`is_read`)
|
KEY `idx_school_id` (`school_id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='通知表';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='通知表';
|
||||||
|
|
||||||
-- 5. 课程表
|
-- 5. 课程表
|
||||||
|
|||||||
@ -219,6 +219,7 @@ public class SysNotificationServiceImpl implements SysNotificationService {
|
|||||||
String content, Integer type, Long senderId,
|
String content, Integer type, Long senderId,
|
||||||
String senderName, Integer targetType) {
|
String senderName, Integer targetType) {
|
||||||
SysNotification notification = new SysNotification();
|
SysNotification notification = new SysNotification();
|
||||||
|
notification.setId(System.currentTimeMillis());
|
||||||
notification.setSchoolId(schoolId);
|
notification.setSchoolId(schoolId);
|
||||||
notification.setUserId(userId);
|
notification.setUserId(userId);
|
||||||
notification.setTitle(title);
|
notification.setTitle(title);
|
||||||
|
|||||||
@ -121,11 +121,11 @@
|
|||||||
WHERE user_id = #{userId} AND school_id = #{schoolId} AND is_read = 0
|
WHERE user_id = #{userId} AND school_id = #{schoolId} AND is_read = 0
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="batchInsert" useGeneratedKeys="true" keyProperty="id">
|
<insert id="batchInsert">
|
||||||
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
|
VALUES
|
||||||
<foreach collection="list" item="item" separator=",">
|
<foreach collection="list" item="item" separator=",">
|
||||||
(#{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})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user