From 4e11f623b0f141b0fbcb10002374fcb0a6124ef5 Mon Sep 17 00:00:00 2001 From: wanjia <553039491@qq.com> Date: Mon, 14 Feb 2022 14:58:39 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BA=A2=E5=B1=B1?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../constant/NotificationSystemConstant.java | 2 ++ db/osredm-gns-notification.sql | 27 +++++++++++++++++++ middleware/end_docker_compose.sh | 0 middleware/services.yml | 1 + middleware/start_docker_compose.sh | 0 5 files changed, 30 insertions(+) create mode 100644 db/osredm-gns-notification.sql mode change 100755 => 100644 middleware/end_docker_compose.sh mode change 100755 => 100644 middleware/start_docker_compose.sh diff --git a/common/src/main/java/cn/org/gitlink/notification/common/constant/NotificationSystemConstant.java b/common/src/main/java/cn/org/gitlink/notification/common/constant/NotificationSystemConstant.java index 58d6c40..1424d54 100644 --- a/common/src/main/java/cn/org/gitlink/notification/common/constant/NotificationSystemConstant.java +++ b/common/src/main/java/cn/org/gitlink/notification/common/constant/NotificationSystemConstant.java @@ -13,10 +13,12 @@ public class NotificationSystemConstant { //平台编码 public static final String PLATFORM_CODE_GITLINK = "gitlink"; //gitlink平台 public static final String PLATFORM_CODE_HEHUI = "hehui"; //hehui平台 + public static final String PLATFORM_CODE_OSREDM = "osredm"; //红山开源平台 public static final Map PLATFORM_CODE_MAP = new HashMap() { { put("gitlink", PLATFORM_CODE_GITLINK); put("hehui", PLATFORM_CODE_HEHUI); + put("osredm", PLATFORM_CODE_OSREDM); } }; diff --git a/db/osredm-gns-notification.sql b/db/osredm-gns-notification.sql new file mode 100644 index 0000000..582c756 --- /dev/null +++ b/db/osredm-gns-notification.sql @@ -0,0 +1,27 @@ + +USE gitlink_notification; + +-- 2022-02-14 新增红山平台 +INSERT INTO gns_platform_info(platform_code,platform_name,created_at,is_delete) VALUES('osredm','红山平台',NOW(),-1); + +DROP TABLE IF EXISTS `osredm_sys_notification`; +CREATE TABLE `osredm_sys_notification` ( + `id` INT NOT NULL AUTO_INCREMENT, + `sender` INT(11) NOT NULL COMMENT '发送者id', + `receiver` INT(11) NOT NULL COMMENT '接受者id', + `content` TEXT NOT NULL COMMENT '消息内容:富文本', + `notification_url` VARCHAR(2000) DEFAULT NULL COMMENT '消息跳转链接', + `created_at` DATETIME NOT NULL DEFAULT NOW() COMMENT '创建时间', + `status` TINYINT(4) NOT NULL DEFAULT 1 COMMENT '已读状态: 1未读,2已读', + `is_delete` TINYINT(1) NOT NULL DEFAULT '-1' COMMENT '是否删除: -1未删除,1已删除', + PRIMARY KEY (`id`), + KEY `index_on_receiver_and_status` (`receiver`,`status`), + KEY `index_on_status` (`status`) +) ENGINE=INNODB DEFAULT CHARSET=utf8mb3; + +-- 2021-09-10 区分系统消息类型 +ALTER TABLE osredm_sys_notification ADD COLUMN (`type` TINYINT(4) NOT NULL DEFAULT 1 COMMENT '消息类型: 1系统消息,2@我'); + +-- 2021-09-10 新增 source 字段区分消息来源、新增 extra 字段保存额外信息 +ALTER TABLE osredm_sys_notification ADD source varchar(250) NULL COMMENT '消息来源'; +ALTER TABLE osredm_sys_notification ADD extra TEXT NULL COMMENT '额外信息(备用字段)'; \ No newline at end of file diff --git a/middleware/end_docker_compose.sh b/middleware/end_docker_compose.sh old mode 100755 new mode 100644 diff --git a/middleware/services.yml b/middleware/services.yml index bb1bb8f..3ed5fd8 100644 --- a/middleware/services.yml +++ b/middleware/services.yml @@ -16,6 +16,7 @@ services: - ${SQL_SCRIPT_PATH}/gns-notification.sql:/docker-entrypoint-initdb.d/0001.sql - ${SQL_SCRIPT_PATH}/hehui-gns-notification.sql:/docker-entrypoint-initdb.d/0002.sql - ${SQL_SCRIPT_PATH}/gns-email.sql:/docker-entrypoint-initdb.d/0003.sql + - ${SQL_SCRIPT_PATH}/osredm-gns-notification.sql:/docker-entrypoint-initdb.d/0004.sql command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci ports: - ${MYSQL_LOCAL_PORT}:3306 diff --git a/middleware/start_docker_compose.sh b/middleware/start_docker_compose.sh old mode 100755 new mode 100644 -- 2.34.1 From 4210e4843bc376682afc91ee9adce6d77d914037 Mon Sep 17 00:00:00 2001 From: wanjia <553039491@qq.com> Date: Fri, 12 Aug 2022 14:04:32 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=8F=91=E9=80=81=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8D=95=E8=8E=B7=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/executor/service/email/EmailService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/executor/src/main/java/cn/org/gitlink/notification/executor/service/email/EmailService.java b/executor/src/main/java/cn/org/gitlink/notification/executor/service/email/EmailService.java index ae533a0..0f060b3 100644 --- a/executor/src/main/java/cn/org/gitlink/notification/executor/service/email/EmailService.java +++ b/executor/src/main/java/cn/org/gitlink/notification/executor/service/email/EmailService.java @@ -95,7 +95,7 @@ public class EmailService { flag = true; unSentEmailSendRecord.setSentAt(new Date()); unSentEmailSendRecord.setStatus(flag ? NotificationSystemConstant.EMAIL_SENT_SUCCESS : NotificationSystemConstant.EMAIL_SENT_FAIL); - } catch (MessagingException e) { + } catch (Exception e) { logger.error("发送邮件失败,email: " + unSentEmailSendRecord.getEmail() + "\n" + e); } } -- 2.34.1 From a7c8fc105f6fb6a7d89512da7b3c9d5353e8641b Mon Sep 17 00:00:00 2001 From: wanjia <553039491@qq.com> Date: Fri, 12 Aug 2022 14:24:39 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E5=8F=91=E9=80=81=E5=A4=B1=E8=B4=A5=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/executor/service/email/EmailService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/executor/src/main/java/cn/org/gitlink/notification/executor/service/email/EmailService.java b/executor/src/main/java/cn/org/gitlink/notification/executor/service/email/EmailService.java index 0f060b3..aa46ef5 100644 --- a/executor/src/main/java/cn/org/gitlink/notification/executor/service/email/EmailService.java +++ b/executor/src/main/java/cn/org/gitlink/notification/executor/service/email/EmailService.java @@ -96,6 +96,7 @@ public class EmailService { unSentEmailSendRecord.setSentAt(new Date()); unSentEmailSendRecord.setStatus(flag ? NotificationSystemConstant.EMAIL_SENT_SUCCESS : NotificationSystemConstant.EMAIL_SENT_FAIL); } catch (Exception e) { + unSentEmailSendRecord.setStatus(NotificationSystemConstant.EMAIL_SENT_FAIL); logger.error("发送邮件失败,email: " + unSentEmailSendRecord.getEmail() + "\n" + e); } } -- 2.34.1 From 2f3bdd12da0f6d90332c061ea737f48548ae3faf Mon Sep 17 00:00:00 2001 From: wanjia <553039491@qq.com> Date: Tue, 25 Oct 2022 09:33:56 +0800 Subject: [PATCH 4/4] API:add param for notification list --- .../model/dao/mapper/SysNotificationMapper.java | 1 + .../service/notification/SysNotificationService.java | 9 +++++---- .../impl/SysNotificationServiceImpl.java | 12 ++++++------ .../mapper/notification/SysNotificationMapper.xml | 3 +++ .../model/service/notification/ServiceTests.java | 2 +- .../reader/controller/NotificationController.java | 5 ++++- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/model/src/main/java/cn/org/gitlink/notification/model/dao/mapper/SysNotificationMapper.java b/model/src/main/java/cn/org/gitlink/notification/model/dao/mapper/SysNotificationMapper.java index bffd80f..88d5d37 100644 --- a/model/src/main/java/cn/org/gitlink/notification/model/dao/mapper/SysNotificationMapper.java +++ b/model/src/main/java/cn/org/gitlink/notification/model/dao/mapper/SysNotificationMapper.java @@ -39,6 +39,7 @@ public interface SysNotificationMapper extends BaseMapper { List getSysNotificationPageList(Page page, String orderBy, @Param("type") int type, + @Param("source") String source, @Param("platform") String platform, @Param("receiver") Integer receiver, @Param("status") Integer status); diff --git a/model/src/main/java/cn/org/gitlink/notification/model/service/notification/SysNotificationService.java b/model/src/main/java/cn/org/gitlink/notification/model/service/notification/SysNotificationService.java index adc99b1..0c92047 100644 --- a/model/src/main/java/cn/org/gitlink/notification/model/service/notification/SysNotificationService.java +++ b/model/src/main/java/cn/org/gitlink/notification/model/service/notification/SysNotificationService.java @@ -36,16 +36,17 @@ public interface SysNotificationService extends IService { /** * 获取消息列表 * - * @param type 类型 -1 全部 1 系统消息、2 @我 - * @param page 页码 - * @param size 页大小 * @param platform 平台编号 * @param receiver 消息接收者 * @param status 状态 -1 全部、1 未读 2 已读 + * @param type 类型 -1 全部 1 系统消息、2 @我 + * @param source + * @param page 页码 + * @param size 页大小 * @return */ - Page getNotification(String platform, Integer receiver, Integer status, Integer type, Integer page, Integer size) throws Exception; + Page getNotification(String platform, Integer receiver, Integer status, Integer type, String source, Integer page, Integer size) throws Exception; /** * @Description: 批量删除系统消息 diff --git a/model/src/main/java/cn/org/gitlink/notification/model/service/notification/impl/SysNotificationServiceImpl.java b/model/src/main/java/cn/org/gitlink/notification/model/service/notification/impl/SysNotificationServiceImpl.java index 79a059c..5cf17cd 100644 --- a/model/src/main/java/cn/org/gitlink/notification/model/service/notification/impl/SysNotificationServiceImpl.java +++ b/model/src/main/java/cn/org/gitlink/notification/model/service/notification/impl/SysNotificationServiceImpl.java @@ -28,7 +28,7 @@ public class SysNotificationServiceImpl extends ServiceImpl sysNotificationList = new ArrayList<>(); List list = Arrays.asList(newSysNotificationVo.getReceivers().split(",")); for (String receiver : list) { @@ -51,7 +51,7 @@ public class SysNotificationServiceImpl extends ServiceImpl 0) { this.delUserCache(platform, receiver); @@ -60,7 +60,7 @@ public class SysNotificationServiceImpl extends ServiceImpl getNotification(String platform, Integer receiver, Integer status, Integer type, Integer page, Integer size) throws Exception { + public Page getNotification(String platform, Integer receiver, Integer status, Integer type, String source, Integer page, Integer size) { String cacheKey = cacheKeyForPage(platform, receiver, type, status, page, size); Object foundResult = this.redisUtil.get(cacheKey); if (foundResult != null) { @@ -82,7 +82,7 @@ public class SysNotificationServiceImpl extends ServiceImpl pageItem = new Page(page, size); List sysNotificationList = baseMapper.getSysNotificationPageList( - pageItem, "", type, platform, receiver, status + pageItem, "", type, source, platform, receiver, status ); pageItem.setRecords(sysNotificationList); this.redisUtil.set(cacheKey, pageItem); @@ -90,7 +90,7 @@ public class SysNotificationServiceImpl extends ServiceImpl 0) { this.delUserCache(platform, receiver); diff --git a/model/src/main/resources/mapper/notification/SysNotificationMapper.xml b/model/src/main/resources/mapper/notification/SysNotificationMapper.xml index 6dfbd6b..87a5808 100644 --- a/model/src/main/resources/mapper/notification/SysNotificationMapper.xml +++ b/model/src/main/resources/mapper/notification/SysNotificationMapper.xml @@ -202,6 +202,9 @@ and status = #{status} + + and source = #{source} + ORDER BY id DESC diff --git a/model/src/test/java/cn/org/gitlink/notification/model/service/notification/ServiceTests.java b/model/src/test/java/cn/org/gitlink/notification/model/service/notification/ServiceTests.java index 9aae278..d1ab2d7 100644 --- a/model/src/test/java/cn/org/gitlink/notification/model/service/notification/ServiceTests.java +++ b/model/src/test/java/cn/org/gitlink/notification/model/service/notification/ServiceTests.java @@ -28,7 +28,7 @@ public class ServiceTests { @Test public void testSysNotificationService() throws Exception { int i = sysNotificationService.getNotificationCount("gitlink", 234,1,1); - Page sysNotificationPage = sysNotificationService.getNotification("gitlink", 100,1,1,1,20); + Page sysNotificationPage = sysNotificationService.getNotification("gitlink", 100,1,1, "IssueChanged", 1,20); NewSysNotificationVo newSysNotificationVo = new NewSysNotificationVo(); newSysNotificationVo.setSender(1); newSysNotificationVo.setReceivers("7,8"); diff --git a/reader/src/main/java/cn/org/gitlink/notification/reader/controller/NotificationController.java b/reader/src/main/java/cn/org/gitlink/notification/reader/controller/NotificationController.java index 4db22aa..5368bd3 100644 --- a/reader/src/main/java/cn/org/gitlink/notification/reader/controller/NotificationController.java +++ b/reader/src/main/java/cn/org/gitlink/notification/reader/controller/NotificationController.java @@ -52,6 +52,9 @@ public class NotificationController { @ApiParam(value = "消息类型:值为-1时,获取全部信息;值为1时,获取系统消息;值为2时,获取@我消息", defaultValue = "-1") @RequestParam(name = "type", required = false, defaultValue = "-1") Integer type, + @ApiParam(value = "消息来源") + @RequestParam(name = "source", required = false) String source, + @ApiParam(value = "页码:值为-1时(默认值),不开启分页;", required = false, defaultValue = "-1") @RequestParam(name = "page", required = false, defaultValue = "-1") Integer page, @@ -88,7 +91,7 @@ public class NotificationController { } //分页的数据 - Page foundPage = notificationService.getNotification(platform, receiver, status, type, page, size); + Page foundPage = notificationService.getNotification(platform, receiver, status, type, source, page, size); if (foundPage != null) { notificationListVo.setPageNum(foundPage.getCurrent()); notificationListVo.setPageSize(foundPage.getSize()); -- 2.34.1