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] 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());