wlzboy
2 天以前 8cb5d3440208a3be3e772e65f1bd0ec63031ba62
sql/sys_notify_send_log.sql
@@ -3,34 +3,36 @@
-- 用于记录各类通知消息的发送记录,实现防重机制
-- 确保同一任务同一人同一通知类型只发送一次
-- ===========================================
DROP TABLE IF EXISTS `sys_notify_send_log`;
CREATE TABLE `sys_notify_send_log` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `task_id` bigint(20) NOT NULL COMMENT '任务ID',
  `user_id` bigint(20) NOT NULL COMMENT '接收用户ID',
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `notify_task_id` bigint DEFAULT NULL COMMENT '关联的通知任务ID',
  `task_id` bigint NOT NULL COMMENT '任务ID',
  `user_id` bigint NOT NULL COMMENT '接收用户ID',
  `user_name` varchar(64) DEFAULT NULL COMMENT '接收用户姓名',
  `notify_type` varchar(32) NOT NULL COMMENT '通知类型:TASK_ASSIGN-任务分配, STATUS_CHANGE-状态变更, TASK_CREATE-任务创建',
  `channel` varchar(32) NOT NULL COMMENT '通知渠道:WECHAT-微信订阅消息, SMS-短信, APP_PUSH-APP推送, SITE_MSG-站内消息',
  `send_content` text,
  `send_status` char(1) DEFAULT '0' COMMENT '发送状态:0-待发送, 1-发送成功, 2-发送失败',
  `send_content` text COMMENT '发送的内容',
  `send_time` datetime DEFAULT NULL COMMENT '发送时间',
  `send_result` text DEFAULT NULL COMMENT '发送结果/错误信息',
  `retry_count` int(11) DEFAULT 0 COMMENT '重试次数',
  `send_result` varchar(500) DEFAULT NULL COMMENT '发送结果/错误信息',
  `retry_count` int DEFAULT '0' COMMENT '重试次数',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `create_by` varchar(64) DEFAULT '' COMMENT '创建者',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `update_by` varchar(64) DEFAULT '' COMMENT '更新者',
  `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  `response_msg` text COMMENT '响应消息',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_task_user_type_channel` (`task_id`, `user_id`, `notify_type`, `channel`) COMMENT '同一任务同一用户同一类型同一渠道只能有一条记录',
  KEY `idx_task_id` (`task_id`),
  KEY `idx_user_id` (`user_id`),
  KEY `idx_notify_type` (`notify_type`),
  KEY `idx_send_status` (`send_status`),
  KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='通知发送记录表';
  KEY `idx_create_time` (`create_time`),
  KEY `idx_notify_task_id` (`notify_task_id`)
) ENGINE=InnoDB AUTO_INCREMENT=64 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='通知发送记录表';
-- ===========================================
-- 使用说明: