diff --git a/cloud-common-websocket/src/main/java/com/cm/websocket/controller/resource/message/MessageResourceController.java b/cloud-common-websocket/src/main/java/com/cm/websocket/controller/resource/message/MessageResourceController.java index 04b5c39..a95556e 100644 --- a/cloud-common-websocket/src/main/java/com/cm/websocket/controller/resource/message/MessageResourceController.java +++ b/cloud-common-websocket/src/main/java/com/cm/websocket/controller/resource/message/MessageResourceController.java @@ -49,7 +49,7 @@ public class MessageResourceController { @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @PostMapping("noticewithtarget/save") @CheckRequestBodyAnnotation - public SuccessResult saveNoticeWithTargetAndSave(@RequestBody NoticeVO noticeVO) throws Exception { + public synchronized SuccessResult saveNoticeWithTargetAndSave(@RequestBody NoticeVO noticeVO) throws Exception { return messageService.saveNoticeWithTarget(noticeVO, true); } diff --git a/cloud-common-websocket/src/main/java/com/cm/websocket/dao/INoticeDao.java b/cloud-common-websocket/src/main/java/com/cm/websocket/dao/INoticeDao.java index 683071d..f23e93b 100644 --- a/cloud-common-websocket/src/main/java/com/cm/websocket/dao/INoticeDao.java +++ b/cloud-common-websocket/src/main/java/com/cm/websocket/dao/INoticeDao.java @@ -38,6 +38,15 @@ public interface INoticeDao { */ void updateHandle(Map params) throws UpdateException; + /** + * 详情 + * + * @param params + * @return + * @throws SearchException + */ + NoticePO getPO(Map params) throws SearchException; + /** * 列表 * @@ -82,4 +91,5 @@ public interface INoticeDao { * @throws SearchException */ Integer count(Map params) throws SearchException; + } diff --git a/cloud-common-websocket/src/main/java/com/cm/websocket/service/INoticeService.java b/cloud-common-websocket/src/main/java/com/cm/websocket/service/INoticeService.java index ae6a163..9295bf1 100644 --- a/cloud-common-websocket/src/main/java/com/cm/websocket/service/INoticeService.java +++ b/cloud-common-websocket/src/main/java/com/cm/websocket/service/INoticeService.java @@ -1,6 +1,7 @@ package com.cm.websocket.service; import com.cm.websocket.pojo.AppSocketMessage; +import com.cm.websocket.pojo.pos.NoticePO; import com.cm.websocket.pojo.vos.message.NoticeVO; import java.util.List; @@ -35,6 +36,106 @@ public interface INoticeService { */ void updateHandleStatus(String userId, AppSocketMessage.CountNeedToDealWithBody countNeedToDealWithBody); + /** + * 通知详情 + * + * @param params + * @return + */ + NoticePO getPO(Map params); + + /** + * 通知详情 + * + * @param serviceId + * @param userId + * @return + */ + NoticePO getPO(String serviceId, String userId); + + /** + * 通知详情 + * + * @param system + * @param serviceId + * @param userId + * @return + */ + NoticePO getPO(String system, String serviceId, String userId); + + /** + * 通知详情 + * + * @param system + * @param module + * @param serviceId + * @param userId + * @return + */ + NoticePO getPO(String system, String module, String serviceId, String userId); + + /** + * 通知详情 + * + * @param system + * @param module + * @param menu + * @param serviceId + * @param userId + * @return + */ + NoticePO getPO(String system, String module, String menu, String serviceId, String userId); + + /** + * 通知列表 + * + * @param params + * @return + */ + List listPO(Map params); + + /** + * 通知列表 + * + * @param serviceId + * @param userId + * @return + */ + List listPO(String serviceId, String userId); + + /** + * 通知列表 + * + * @param system + * @param serviceId + * @param userId + * @return + */ + List listPO(String system, String serviceId, String userId); + + /** + * 通知列表 + * + * @param system + * @param module + * @param serviceId + * @param userId + * @return + */ + List listPO(String system, String module, String serviceId, String userId); + + /** + * 通知列表 + * + * @param system + * @param module + * @param menu + * @param serviceId + * @param userId + * @return + */ + List listPO(String system, String module, String menu, String serviceId, String userId); + /** * 通知数量 * diff --git a/cloud-common-websocket/src/main/java/com/cm/websocket/service/impl/NoticeServiceImpl.java b/cloud-common-websocket/src/main/java/com/cm/websocket/service/impl/NoticeServiceImpl.java index 54f5dc9..74e5ab3 100644 --- a/cloud-common-websocket/src/main/java/com/cm/websocket/service/impl/NoticeServiceImpl.java +++ b/cloud-common-websocket/src/main/java/com/cm/websocket/service/impl/NoticeServiceImpl.java @@ -4,6 +4,7 @@ import com.cm.common.base.AbstractService; import com.cm.common.utils.UUIDUtil; import com.cm.websocket.dao.INoticeDao; import com.cm.websocket.pojo.AppSocketMessage; +import com.cm.websocket.pojo.pos.NoticePO; import com.cm.websocket.pojo.vos.message.NoticeVO; import com.cm.websocket.service.INoticeService; import org.apache.commons.lang3.StringUtils; @@ -32,6 +33,20 @@ public class NoticeServiceImpl extends AbstractService implements INoticeService @Override public void save(String userId, NoticeVO.Notice notice) throws Exception { + if (StringUtils.isBlank(userId)) { + return; + } + if (StringUtils.isBlank(notice.getSystem())) { + return; + } + if (StringUtils.isBlank(notice.getServiceId())) { + return; + } + List noticePOs = listPO(notice.getSystem(), notice.getModule(), notice.getMenu(), notice.getServiceId(), userId); + if (!noticePOs.isEmpty()) { + LOG.debug("通知已经存在"); + return; + } Map params = getHashMap(16); params.put("noticeId", UUIDUtil.getUUID()); params.put("userId", userId); @@ -63,6 +78,92 @@ public class NoticeServiceImpl extends AbstractService implements INoticeService noticeDao.updateHandle(params); } + @Override + public NoticePO getPO(Map params) { + return noticeDao.getPO(params); + } + + @Override + public NoticePO getPO(String serviceId, String userId) { + Map params = getHashMap(4); + params.put("noticeServiceId", serviceId); + params.put("userId", userId); + return getPO(params); + } + + @Override + public NoticePO getPO(String system, String serviceId, String userId) { + Map params = getHashMap(6); + params.put("noticeSystem", system); + params.put("noticeServiceId", serviceId); + params.put("userId", userId); + return getPO(params); + } + + @Override + public NoticePO getPO(String system, String module, String serviceId, String userId) { + Map params = getHashMap(8); + params.put("noticeSystem", system); + params.put("noticeModule", module); + params.put("noticeServiceId", serviceId); + params.put("userId", userId); + return getPO(params); + } + + @Override + public NoticePO getPO(String system, String module, String menu, String serviceId, String userId) { + Map params = getHashMap(10); + params.put("noticeSystem", system); + params.put("noticeModule", module); + params.put("noticeMenu", menu); + params.put("noticeServiceId", serviceId); + params.put("userId", userId); + return getPO(params); + } + + @Override + public List listPO(Map params) { + return noticeDao.listPO(params); + } + + @Override + public List listPO(String serviceId, String userId) { + Map params = getHashMap(4); + params.put("noticeServiceId", serviceId); + params.put("userId", userId); + return listPO(params); + } + + @Override + public List listPO(String system, String serviceId, String userId) { + Map params = getHashMap(6); + params.put("noticeSystem", system); + params.put("noticeServiceId", serviceId); + params.put("userId", userId); + return listPO(params); + } + + @Override + public List listPO(String system, String module, String serviceId, String userId) { + Map params = getHashMap(8); + params.put("noticeSystem", system); + params.put("noticeModule", module); + params.put("noticeServiceId", serviceId); + params.put("userId", userId); + return listPO(params); + } + + @Override + public List listPO(String system, String module, String menu, String serviceId, String userId) { + Map params = getHashMap(10); + params.put("noticeSystem", system); + params.put("noticeModule", module); + params.put("noticeMenu", menu); + params.put("noticeServiceId", serviceId); + params.put("userId", userId); + return listPO(params); + } + @Override public List listNoticeCount(String userId, AppSocketMessage.CountNeedToDealWithBody countNeedToDealWithBody) { List noticeCounts = new ArrayList<>(); diff --git a/cloud-common-websocket/src/main/resources/mybatis/mapper/notice-mapper.xml b/cloud-common-websocket/src/main/resources/mybatis/mapper/notice-mapper.xml index 16d3502..f3a3c90 100644 --- a/cloud-common-websocket/src/main/resources/mybatis/mapper/notice-mapper.xml +++ b/cloud-common-websocket/src/main/resources/mybatis/mapper/notice-mapper.xml @@ -72,6 +72,54 @@ notice_service_id = #{noticeServiceId} + + +