From 837a2f7abad2d0fea966f6df12dc126ce3973fec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=B4=E6=8B=89=E8=BF=AA=E7=BB=B4?= Date: Thu, 9 Sep 2021 10:20:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4Reader=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 + .../entity/vo/ReceiverNotificationListVo.java | 92 +++++---- .../dao/mapper/SysNotificationMapper.java | 1 + .../notification/SysNotificationService.java | 31 ++-- .../impl/SysNotificationServiceImpl.java | 20 +- .../notification/SysNotificationMapper.xml | 175 +++++++++--------- .../service/notification/ServiceTests.java | 30 +-- .../controller/NotificationController.java | 110 ++++++++--- 8 files changed, 272 insertions(+), 189 deletions(-) diff --git a/.gitignore b/.gitignore index 00e4e1b..7083f96 100644 --- a/.gitignore +++ b/.gitignore @@ -90,3 +90,5 @@ target/ .env /docker-data/ + +/logs/ diff --git a/model/src/main/java/cn/org/gitlink/notification/model/dao/entity/vo/ReceiverNotificationListVo.java b/model/src/main/java/cn/org/gitlink/notification/model/dao/entity/vo/ReceiverNotificationListVo.java index 793acea..3086d41 100644 --- a/model/src/main/java/cn/org/gitlink/notification/model/dao/entity/vo/ReceiverNotificationListVo.java +++ b/model/src/main/java/cn/org/gitlink/notification/model/dao/entity/vo/ReceiverNotificationListVo.java @@ -1,6 +1,7 @@ package cn.org.gitlink.notification.model.dao.entity.vo; import cn.org.gitlink.notification.model.dao.entity.SysNotification; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; @@ -20,41 +21,24 @@ public class ReceiverNotificationListVo { @JsonProperty("unread_atme") private Integer unreadAtMeCount; - @JsonProperty("notification_list") - private List notificationList; + @JsonProperty("records") + private List records; - @JsonProperty("atme_list") - private List atMeList; + @JsonProperty("records_count") + private long recordsCount; + + @JsonProperty("page_num") + private long pageNum; + + @JsonProperty("total_page_count") + private long totalPageCount; + + @JsonProperty("page_size") + private long pageSize; public ReceiverNotificationListVo() { } - public ReceiverNotificationListVo(Integer receiver, Integer type, Integer totalUnreadNotifiationCount, Integer unreadNotificationCount, Integer unreadAtMeCount, List notificationList, List atMeList) { - this.receiver = receiver; - this.type = type; - this.totalUnreadNotifiationCount = totalUnreadNotifiationCount; - this.unreadNotificationCount = unreadNotificationCount; - this.unreadAtMeCount = unreadAtMeCount; - this.notificationList = notificationList; - this.atMeList = atMeList; - } - - public Integer getTotalUnreadNotifiationCount() { - return totalUnreadNotifiationCount; - } - - public void setTotalUnreadNotifiationCount(Integer totalUnreadNotifiationCount) { - this.totalUnreadNotifiationCount = totalUnreadNotifiationCount; - } - - public List getAtMeList() { - return atMeList; - } - - public void setAtMeList(List atMeList) { - this.atMeList = atMeList; - } - public Integer getReceiver() { return receiver; } @@ -71,6 +55,14 @@ public class ReceiverNotificationListVo { this.type = type; } + public Integer getTotalUnreadNotifiationCount() { + return totalUnreadNotifiationCount; + } + + public void setTotalUnreadNotifiationCount(Integer totalUnreadNotifiationCount) { + this.totalUnreadNotifiationCount = totalUnreadNotifiationCount; + } + public Integer getUnreadNotificationCount() { return unreadNotificationCount; } @@ -87,11 +79,43 @@ public class ReceiverNotificationListVo { this.unreadAtMeCount = unreadAtMeCount; } - public List getNotificationList() { - return notificationList; + public List getRecords() { + return records; } - public void setNotificationList(List notificationList) { - this.notificationList = notificationList; + public void setRecords(List records) { + this.records = records; + } + + public long getRecordsCount() { + return recordsCount; + } + + public void setRecordsCount(long recordsCount) { + this.recordsCount = recordsCount; + } + + public long getPageNum() { + return pageNum; + } + + public void setPageNum(long pageNum) { + this.pageNum = pageNum; + } + + public long getTotalPageCount() { + return totalPageCount; + } + + public void setTotalPageCount(long totalPageCount) { + this.totalPageCount = totalPageCount; + } + + public long getPageSize() { + return pageSize; + } + + public void setPageSize(long pageSize) { + this.pageSize = pageSize; } } 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 b7a7d48..609dd8f 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 @@ -34,6 +34,7 @@ public interface SysNotificationMapper extends BaseMapper { @Param("type") Integer type); List getSysNotificationPageList(Page page, String orderBy, + @Param("type") int type, @Param("platform") String platform, @Param("receiver") Integer receiver); 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 a0565c5..c68435f 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 @@ -10,17 +10,17 @@ import java.util.List; public interface SysNotificationService extends IService { //给用户发送消息 - boolean sendNotification(NewSysNotificationVo sysNotification); + boolean sendNotification(NewSysNotificationVo sysNotification) throws Exception; /** * 设置系统消息状态为: * - * @param platform 平台编号 + * @param platform 平台编号 * @param notificationIds 消息编号列表,中英文逗号隔开,eg:221,2323,4,111,23123 - * @param status 1 未读 2已读 + * @param status 1 未读 2已读 * @return */ - int markNotificationAs(String platform, String notificationIds, Integer status); + int markNotificationAs(String platform, String notificationIds, Integer status) throws Exception; /** * 获取所有未读消息总数 @@ -29,38 +29,39 @@ public interface SysNotificationService extends IService { * @param receiver 信息接收者 * @return */ - int getUnreadNotificationCount(String platform, Integer receiver); + int getUnreadNotificationCount(String platform, Integer receiver) throws Exception; /** * 获取所有未读消息 * * @param platform 平台编号 * @param receiver 消息接收者 - * @param size 页大小 - * @param type 1 系统消息 2 @我 + * @param size 页大小 + * @param type 1 系统消息 2 @我 * @return */ - List getUnreadNotificationByType(String platform, Integer receiver, Integer size, Integer type); + List getUnreadNotificationByType(String platform, Integer receiver, Integer size, Integer type) throws Exception; /** - *按分类获取未读消息总数 + * 按分类获取未读消息总数 * - * @param type 1 系统消息 2 @我 + * @param type 1 系统消息 2 @我 * @param platform 平台编号 * @param receiver 消息接收者 * @return */ - int getUnreadNotificationByType(Integer type, String platform, Integer receiver); + int getUnreadNotificationByType(Integer type, String platform, Integer receiver) throws Exception; /** * 获取所有系统消息 * - * @param page 页码 - * @param size 页大小 - * @param orderBy 排序 + * @param type 类型 -1 全部 1 系统消息、2 @我 + * @param page 页码 + * @param size 页大小 + * @param orderBy 排序 * @param platform 平台编号 * @param receiver 消息接收者 * @return */ - Page getNotification(int page, int size, String orderBy, String platform, Integer receiver); + Page getNotification(int type, int page, int size, String orderBy, String platform, Integer receiver) throws Exception; } 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 cff7161..9b95906 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 @@ -17,7 +17,7 @@ public class SysNotificationServiceImpl extends ServiceImpl getUnreadNotificationByType(String platform, Integer receiver, Integer size, Integer type) { + public List getUnreadNotificationByType(String platform, Integer receiver, Integer size, Integer type) throws Exception { List sysNotificationList = baseMapper.getUnreadSysNotificationsList(platform, receiver, 1, size, type); return sysNotificationList; } @Override - public int getUnreadNotificationByType(Integer type, String platform, Integer receiver) { + public int getUnreadNotificationByType(Integer type, String platform, Integer receiver) throws Exception { return baseMapper.getSysNotificationNumberByType(platform, receiver, type); } @Override - public Page getNotification(int curPage, int pageSize, String orderBy, String platform, Integer receiver) { - Page page = new Page(curPage, pageSize); + public Page getNotification(int type, int page, int size, String orderBy, String platform, Integer receiver) throws Exception { + Page pageItem = new Page(page, size); List sysNotificationList = baseMapper.getSysNotificationPageList( - page, orderBy, platform, receiver + pageItem, orderBy, type, platform, receiver ); - page.setRecords(sysNotificationList); - return page; + pageItem.setRecords(sysNotificationList); + return pageItem; } } diff --git a/model/src/main/resources/mapper/notification/SysNotificationMapper.xml b/model/src/main/resources/mapper/notification/SysNotificationMapper.xml index 31c6c39..5d2975e 100644 --- a/model/src/main/resources/mapper/notification/SysNotificationMapper.xml +++ b/model/src/main/resources/mapper/notification/SysNotificationMapper.xml @@ -1,162 +1,167 @@ - - - - - - - - - - - + + + + + + + + + + + - - id, sender, receiver, content, notification_url, created_at, status, type, is_delete - - select - + from ${platform}_sys_notification where id = #{id,jdbcType=INTEGER} - - delete from ${platform}_sys_notification - where id = #{id,jdbcType=INTEGER} - - - insert into ${platform}_sys_notification (id, sender, receiver, - content, notification_url, - status, type) - values (#{record.id,jdbcType=INTEGER}, #{record.sender,jdbcType=INTEGER}, #{record.receiver,jdbcType=INTEGER}, - #{record.content,jdbcType=VARCHAR}, #{record.notificationUrl,jdbcType=VARCHAR}, - #{record.status,jdbcType=TINYINT}, #{record.type,jdbcType=TINYINT}) - - + + delete from ${platform}_sys_notification + where id = #{id,jdbcType=INTEGER} + + + insert into ${platform}_sys_notification (id, sender, receiver, + content, notification_url, + status, type) + values (#{record.id,jdbcType=INTEGER}, #{record.sender,jdbcType=INTEGER}, #{record.receiver,jdbcType=INTEGER}, + #{record.content,jdbcType=VARCHAR}, #{record.notificationUrl,jdbcType=VARCHAR}, + #{record.status,jdbcType=TINYINT}, #{record.type,jdbcType=TINYINT}) + + insert into ${platform}_sys_notification - - + + id, - + sender, - + receiver, - + content, - + notification_url, - + created_at, - + status, - + type, - + is_delete, - - + + #{record.id,jdbcType=INTEGER}, - + #{record.sender,jdbcType=INTEGER}, - + #{record.receiver,jdbcType=INTEGER}, - + #{record.content,jdbcType=VARCHAR}, - + #{record.notificationUrl,jdbcType=VARCHAR}, - + #{record.createdAt,jdbcType=TIMESTAMP}, - + #{record.status,jdbcType=TINYINT}, - + #{record.type,jdbcType=TINYINT}, - + #{record.isDelete,jdbcType=BIT}, - + update ${platform}_sys_notification - - + + sender = #{record.sender,jdbcType=INTEGER}, - + receiver = #{record.receiver,jdbcType=INTEGER}, - + content = #{record.content,jdbcType=VARCHAR}, - + notification_url = #{record.notificationUrl,jdbcType=VARCHAR}, - + created_at = #{record.createdAt,jdbcType=TIMESTAMP}, - + status = #{record.status,jdbcType=TINYINT}, - + status = #{record.type,jdbcType=TINYINT}, - + is_delete = #{record.isDelete,jdbcType=BIT}, where id = #{record.id,jdbcType=INTEGER} - - update ${platform}_sys_notification - set sender = #{sender,jdbcType=INTEGER}, - receiver = #{receiver,jdbcType=INTEGER}, - content = #{content,jdbcType=VARCHAR}, - notification_url = #{notificationUrl,jdbcType=VARCHAR}, - created_at = #{createdAt,jdbcType=TIMESTAMP}, - status = #{status,jdbcType=TINYINT}, - type = #{type,jdbcType=TINYINT}, - is_delete = #{isDelete,jdbcType=BIT} - where id = #{id,jdbcType=INTEGER} - + + update ${platform}_sys_notification + set sender = #{sender,jdbcType=INTEGER}, + receiver = #{receiver,jdbcType=INTEGER}, + content = #{content,jdbcType=VARCHAR}, + notification_url = #{notificationUrl,jdbcType=VARCHAR}, + created_at = #{createdAt,jdbcType=TIMESTAMP}, + status = #{status,jdbcType=TINYINT}, + type = #{type,jdbcType=TINYINT}, + is_delete = #{isDelete,jdbcType=BIT} + where id = #{id,jdbcType=INTEGER} + - update ${platform}_sys_notification set status = #{status} where id in (${notificationIds}) + update ${platform}_sys_notification set status = #{status} where id in (${notificationIds}) - + select * FROM ${platform}_sys_notification + where receiver = #{receiver} AND is_delete = -1 + + and type = #{type} + + ORDER BY id DESC \ No newline at end of file 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 7077b78..194dfad 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 @@ -29,21 +29,21 @@ public class ServiceTests { @Test public void testSysNotificationService() { - int i = sysNotificationService.getUnreadNotificationCount("gitlink", 234); - List sysNotificationList = sysNotificationService.getUnreadNotificationByType("gitlink", 100, 20, 1); - Page sysNotificationPage = sysNotificationService.getNotification(1, 10, "", "gitlink", 100); - NewSysNotificationVo newSysNotificationVo = new NewSysNotificationVo(); - newSysNotificationVo.setSender((long) -1); - newSysNotificationVo.setReceivers("7,8"); - newSysNotificationVo.setContent("baladiwei 在 gitlink-notification-system 修改ReadMe 文件的标题"); - newSysNotificationVo.setNotification_url("www.baidu.com"); - newSysNotificationVo.setPlatform("gitlink"); - boolean j = sysNotificationService.sendNotification(newSysNotificationVo); - logger.info("insertResult:" + j); - int k = sysNotificationService.markNotificationAs("gitlink", "2,3", 2); - logger.info("updateStatus:" + k); - int l = sysNotificationService.getUnreadNotificationByType(1,"gitlink",1); - logger.info("SysNotificationNumber:" + l); +// int i = sysNotificationService.getUnreadNotificationCount("gitlink", 234); +// List sysNotificationList = sysNotificationService.getUnreadNotificationByType("gitlink", 100, 20, 1); +// Page sysNotificationPage = sysNotificationService.getNotification(1, 10, "", "gitlink", 100); +// NewSysNotificationVo newSysNotificationVo = new NewSysNotificationVo(); +// newSysNotificationVo.setSender((long) -1); +// newSysNotificationVo.setReceivers("7,8"); +// newSysNotificationVo.setContent("baladiwei 在 gitlink-notification-system 修改ReadMe 文件的标题"); +// newSysNotificationVo.setNotification_url("www.baidu.com"); +// newSysNotificationVo.setPlatform("gitlink"); +// boolean j = sysNotificationService.sendNotification(newSysNotificationVo); +// logger.info("insertResult:" + j); +// int k = sysNotificationService.markNotificationAs("gitlink", "2,3", 2); +// logger.info("updateStatus:" + k); +// int l = sysNotificationService.getUnreadNotificationByType(1,"gitlink",1); +// logger.info("SysNotificationNumber:" + l); } @Test 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 ecdd558..58bb7b6 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 @@ -3,18 +3,16 @@ package cn.org.gitlink.notification.reader.controller; import cn.org.gitlink.notification.common.response.DataPacketUtil; import cn.org.gitlink.notification.common.response.ResponseData; import cn.org.gitlink.notification.common.utils.RedisUtil; -import cn.org.gitlink.notification.model.dao.entity.SysNotification; import cn.org.gitlink.notification.model.dao.entity.vo.ReceiverNotificationCountVo; import cn.org.gitlink.notification.model.dao.entity.vo.ReceiverNotificationListVo; import cn.org.gitlink.notification.model.service.notification.SysNotificationService; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.web.bind.annotation.*; -import java.util.List; - @RestController @RequestMapping(value = "/gns/notification") public class NotificationController { @@ -27,6 +25,10 @@ public class NotificationController { private static final Integer NOTIFICATION_TYPE_SYS = 1; //系统消息 private static final Integer NOTIFICATION_TYPE_ATME = 2; //@我的消息 + //是否显示全部信息的判断 + private static final Integer SHOW_OPTION_UNREAD = 1; //只显示固定数目的未读消息 + private static final Integer SHOW_OPTION_ALL = 2; //显示所有消息 + @Autowired private RedisUtil redisUtil; @@ -39,16 +41,18 @@ public class NotificationController { /** * 获取系统消息列表 * - * @param platform 平台编码 - * @param receiver 消息接收者 - * @param pageNum 页码 - * @param pageSize 页大小 - * @param type 消息类型 1 系统消息 | 2 at我 + * @param platform 平台 + * @param receiver 消息接收者 + * @param showOptions 显示选项:1 只获取未读消息、2 获取全部消息 + * @param type 消息类型:1 系统消息、2 @我消息 + * @param pageNum 页码(只在 showOptions = 2 是生效) + * @param pageSize 页大小(只在 showOptions = 2 是生效) * @return */ @GetMapping(value = "/{platform}/list") public ResponseData list(@PathVariable(name = "platform", required = true) String platform, @RequestParam(name = "receiver", required = true) Integer receiver, + @RequestParam(name = "show", required = false, defaultValue = "1") Integer showOptions, @RequestParam(name = "type", required = false, defaultValue = "-1") Integer type, @RequestParam(name = "page", required = false, defaultValue = "1") Integer pageNum, @RequestParam(name = "size", required = false, defaultValue = "20") Integer pageSize) { @@ -63,22 +67,48 @@ public class NotificationController { jsonFailResult = validatePageParams(pageNum, pageSize); if (jsonFailResult != null) return jsonFailResult; + jsonFailResult = validateShowOption(showOptions); + if (jsonFailResult != null) return jsonFailResult; + ReceiverNotificationListVo notificationListVo = new ReceiverNotificationListVo(); notificationListVo.setReceiver(receiver); notificationListVo.setType(type); - notificationListVo.setTotalUnreadNotifiationCount(notificationService.getUnreadNotificationCount(platform, receiver)); - notificationListVo.setUnreadNotificationCount(notificationService.getUnreadNotificationByType(NOTIFICATION_TYPE_SYS, platform, receiver)); - notificationListVo.setUnreadAtMeCount(notificationService.getUnreadNotificationByType(NOTIFICATION_TYPE_ATME, platform, receiver)); - if (type == NOTIFICATION_TYPE_ALL) { - notificationListVo.setNotificationList(notificationService.getUnreadNotificationByType(platform, receiver, pageSize, NOTIFICATION_TYPE_SYS)); - notificationListVo.setAtMeList(notificationService.getUnreadNotificationByType(platform, receiver, pageSize, NOTIFICATION_TYPE_ATME)); - } else if (type == NOTIFICATION_TYPE_SYS) { - notificationListVo.setNotificationList(notificationService.getUnreadNotificationByType(platform, receiver, pageSize, NOTIFICATION_TYPE_SYS)); - } else { - notificationListVo.setAtMeList(notificationService.getUnreadNotificationByType(platform, receiver, pageSize, NOTIFICATION_TYPE_ATME)); - } - return DataPacketUtil.jsonSuccessResult(notificationListVo); + try { + //获取全部未读消息总数 + notificationListVo.setTotalUnreadNotifiationCount(notificationService.getUnreadNotificationCount(platform, receiver)); + //获取未读系统消息总数 + notificationListVo.setUnreadNotificationCount(notificationService.getUnreadNotificationByType(NOTIFICATION_TYPE_SYS, platform, receiver)); + //获取未读@我消息总数 + notificationListVo.setUnreadAtMeCount(notificationService.getUnreadNotificationByType(NOTIFICATION_TYPE_ATME, platform, receiver)); + + if (showOptions == SHOW_OPTION_ALL) { + Page foundPage = notificationService.getNotification(type, pageNum, pageSize, "", platform, receiver); + if (foundPage != null) { + notificationListVo.setPageNum(foundPage.getCurrent()); + notificationListVo.setPageSize(foundPage.getSize()); + notificationListVo.setRecordsCount(foundPage.getTotal()); + notificationListVo.setTotalPageCount(foundPage.getPages()); + notificationListVo.setRecords(foundPage.getRecords()); + } + return DataPacketUtil.jsonSuccessResult(notificationListVo); + } + + if (type == NOTIFICATION_TYPE_ALL) { + Page foundPage = notificationService.getNotification(NOTIFICATION_TYPE_ALL, 1, pageSize, "", platform, receiver); + if (foundPage != null) { + notificationListVo.setRecords(foundPage.getRecords()); + } + } else if (type == NOTIFICATION_TYPE_SYS) { + notificationListVo.setRecords(notificationService.getUnreadNotificationByType(platform, receiver, pageSize, NOTIFICATION_TYPE_SYS)); + } else { + notificationListVo.setRecords(notificationService.getUnreadNotificationByType(platform, receiver, pageSize, NOTIFICATION_TYPE_ATME)); + } + return DataPacketUtil.jsonSuccessResult(notificationListVo); + } catch (Exception e) { + logger.error(e); + return DataPacketUtil.jsonFailResult(e.getMessage()); + }//end of try-catch }//end of method @@ -102,18 +132,23 @@ public class NotificationController { if (jsonFailResult != null) return jsonFailResult; int unreadNotificationCount = -1; - if (type == NOTIFICATION_TYPE_ALL) { - unreadNotificationCount = notificationService.getUnreadNotificationCount(platform, receiver); - } else { - unreadNotificationCount = notificationService.getUnreadNotificationByType(type, platform, receiver); - }//end of if-else + try { + if (type == NOTIFICATION_TYPE_ALL) { + unreadNotificationCount = notificationService.getUnreadNotificationCount(platform, receiver); + } else { + unreadNotificationCount = notificationService.getUnreadNotificationByType(type, platform, receiver); + }//end of if-else - ReceiverNotificationCountVo countVo = new ReceiverNotificationCountVo(); - countVo.setReceiver(receiver); - countVo.setType(type); - countVo.setUnreadNotification(unreadNotificationCount); + ReceiverNotificationCountVo countVo = new ReceiverNotificationCountVo(); + countVo.setReceiver(receiver); + countVo.setType(type); + countVo.setUnreadNotification(unreadNotificationCount); - return DataPacketUtil.jsonSuccessResult(countVo); + return DataPacketUtil.jsonSuccessResult(countVo); + } catch (Exception e) { + logger.error(e); + return DataPacketUtil.jsonFailResult(e.getMessage()); + } }//end of method @@ -176,4 +211,19 @@ public class NotificationController { return null; }//end of method + + /** + * 验证 showOption 参数 + * + * @param showOption + * @return + */ + private ResponseData validateShowOption(Integer showOption) { + if (showOption != SHOW_OPTION_UNREAD && showOption != SHOW_OPTION_ALL) { + logger.debug("\t 输入参数 {showOption} 的值 {" + showOption + "} 超出约定范围"); + return DataPacketUtil.jsonFailResult("{show} 参数非法"); + } + return null; + }//end of method + }//end of class