From ad34d7e21910aab6e6aeec63a840f9e1c3e64020 Mon Sep 17 00:00:00 2001 From: xd <844539747@qq.com> Date: Wed, 24 Apr 2024 14:50:22 +0800 Subject: [PATCH] '123' --- .../system/SysNoticeController.java | 11 +++++++++- .../ruoyi/system/domain/SysNoticeUser.java | 22 +++++++++++++++++++ .../src/layout/components/NavbarNotice.vue | 20 +++++++---------- 3 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNoticeUser.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java index 602dd47..d559464 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java @@ -1,5 +1,6 @@ package com.ruoyi.web.controller.system; +import java.util.Collection; import java.util.Comparator; import java.util.List; import java.util.Map; @@ -9,6 +10,7 @@ import com.alibaba.fastjson2.JSONObject; import com.ruoyi.common.constant.WebsocketConst; import com.ruoyi.framework.websocket.WebSocketServer; import com.ruoyi.framework.websocket.WebSocketUsers; +import com.ruoyi.system.domain.SysNoticeUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; @@ -28,6 +30,8 @@ import com.ruoyi.common.enums.BusinessType; import com.ruoyi.system.domain.SysNotice; import com.ruoyi.system.service.ISysNoticeService; +import javax.websocket.Session; + /** * 公告 信息操作处理 * @@ -79,7 +83,12 @@ public class SysNoticeController extends BaseController obj.put(WebsocketConst.MSG_ID, notice.getNoticeId()); obj.put(WebsocketConst.MSG_TITLE, notice.getNoticeTitle()); obj.put(WebsocketConst.MSG_CONTENT, notice.getNoticeContent()); - WebSocketUsers.sendMessageToUsersByText(obj.toString()); + if(!"3".equals(notice.getNoticeType())){//系统通知 或 通知公告 + WebSocketUsers.sendMessageToUsersByText(obj.toString()); + SysNoticeUser sysNoticeUser = new SysNoticeUser(); + sysNoticeUser.setNoticeId(notice.getNoticeId()); + sysNoticeUser.setUserId(notice.getNoticeId()); + } return toAjax(noticeService.insertNotice(notice)); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNoticeUser.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNoticeUser.java new file mode 100644 index 0000000..0c69c09 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNoticeUser.java @@ -0,0 +1,22 @@ +package com.ruoyi.system.domain; + +public class SysNoticeUser { + private Long noticeId; + private Long userId; + + public Long getNoticeId() { + return noticeId; + } + + public void setNoticeId(Long noticeId) { + this.noticeId = noticeId; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } +} diff --git a/ruoyi-ui/src/layout/components/NavbarNotice.vue b/ruoyi-ui/src/layout/components/NavbarNotice.vue index 3531387..53835be 100644 --- a/ruoyi-ui/src/layout/components/NavbarNotice.vue +++ b/ruoyi-ui/src/layout/components/NavbarNotice.vue @@ -9,7 +9,7 @@ - + {{item.noticeTitle}} 更多消息 @@ -39,12 +39,6 @@ data() { return { activeName: 'first', - // 查询参数 - queryParams: { - pageNum: 1, - pageSize: 5, - readFlag: '0' - }, noteTotal: '', // 公告 sysLog: [], @@ -67,12 +61,14 @@ }, methods: { getList() { - this.noticeData = [] - this.sysLog = [] + this.noticeData = []; + this.sysLog = []; navbarNoticelist(this.queryParams).then(res => { - console.log(res[1]) - this.noticeData = res[1]?res[1]:[]; - this.sysLog = res[2]?res[2]:[]; + var noticeData = res[1]?res[1]:[]; + this.noticeData = noticeData.slice(0,5); + + var sysLog = res[2]?res[2]:[]; + this.sysLog = sysLog.slice(0,5); this.noteTotal = this.noticeData.length+this.sysLog.length; })