From 413cc421a806a8bc7647b7503a89a366bec879e5 Mon Sep 17 00:00:00 2001
From: wxl <727869402@qq.com>
Date: Sun, 12 Jan 2025 23:55:59 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9F=A5=E8=AF=A2sql=20?=
=?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=9C=AA=E8=AF=BB=E6=B6=88=E6=81=AF?=
=?UTF-8?q?=E6=95=B0=E9=87=8F=E9=80=9A=E8=BF=87websocket=E8=8E=B7=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../business/chat/mapper/xml/ChatMapper.xml | 4 +-
.../GetApiReadCountMessageHandler.java | 50 +++++++++++++++++++
.../operationLog/operationLogList.vue | 20 ++++----
web/src/views/common/Im.vue | 3 --
4 files changed, 63 insertions(+), 14 deletions(-)
create mode 100644 src/main/java/com/dd/admin/business/webSocket/handler/GetApiReadCountMessageHandler.java
diff --git a/src/main/java/com/dd/admin/business/chat/mapper/xml/ChatMapper.xml b/src/main/java/com/dd/admin/business/chat/mapper/xml/ChatMapper.xml
index 77e3406..e39b1cc 100644
--- a/src/main/java/com/dd/admin/business/chat/mapper/xml/ChatMapper.xml
+++ b/src/main/java/com/dd/admin/business/chat/mapper/xml/ChatMapper.xml
@@ -63,7 +63,7 @@
select * from (
SELECT
a.FROM_ID AS authorId,
- a.FROM_NAME AS authorName,
+ b.AUTHOR_NAME AS authorName,
b.AVATAR_URL AS authorAvatar,
a.content,
a.create_time,
@@ -90,7 +90,7 @@
SELECT
a.TO_ID AS authorId,
- a.TO_NAME AS authorName,
+ b.AUTHOR_NAME AS authorName,
b.AVATAR_URL AS authorAvatar,
a.content,
a.create_time,
diff --git a/src/main/java/com/dd/admin/business/webSocket/handler/GetApiReadCountMessageHandler.java b/src/main/java/com/dd/admin/business/webSocket/handler/GetApiReadCountMessageHandler.java
new file mode 100644
index 0000000..91e78e7
--- /dev/null
+++ b/src/main/java/com/dd/admin/business/webSocket/handler/GetApiReadCountMessageHandler.java
@@ -0,0 +1,50 @@
+package com.dd.admin.business.webSocket.handler;
+
+import com.dd.admin.business.api.domain.UnReadCountBean;
+import com.dd.admin.business.author.service.AuthorService;
+import com.dd.admin.business.chat.service.ChatService;
+import com.dd.admin.business.follow.service.FollowService;
+import com.dd.admin.business.reply.service.ReplyService;
+import com.dd.admin.business.starNotes.service.StarNotesService;
+import com.dd.admin.business.upNotes.service.UpNotesService;
+import com.dd.admin.business.webSocket.MsgHandlerInterface;
+import com.dd.admin.business.webSocket.util.TioUtil;
+import io.swagger.annotations.ApiModel;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.tio.core.ChannelContext;
+
+import java.util.Map;
+
+
+@Slf4j
+@Service("9")
+@ApiModel("获取未读总数Handler")
+public class GetApiReadCountMessageHandler implements MsgHandlerInterface {
+ @Autowired
+ ChatService chatService;
+ @Autowired
+ UpNotesService upNotesService;
+ @Autowired
+ StarNotesService starNotesService;
+ @Autowired
+ ReplyService replyService;
+ @Autowired
+ FollowService followService;
+ @Override
+ public Object handler(Map map, ChannelContext context) {
+ String authorId = String.valueOf(map.get("authorId"));
+ Integer chatUnReadCount = chatService.selectUnReadCount(authorId);
+ Integer upNotesUnReadCount = upNotesService.selectUnReadCount(authorId);
+ Integer starNotesUnReadCount = starNotesService.selectUnReadCount(authorId);
+ Integer replyUnReadCount = replyService.selectUnReadCount(authorId);
+ Integer followUnReadCount = followService.selectUnReadCount(authorId);
+ Integer totalUnReadCount = 0;
+ UnReadCountBean unReadCountBean = new UnReadCountBean(chatUnReadCount,upNotesUnReadCount,starNotesUnReadCount,replyUnReadCount,followUnReadCount,totalUnReadCount);
+ unReadCountBean.calculateTotalUnReadCount();
+
+ TioUtil.sendChatMessageToUser(context.getGroupContext(),authorId,"9",unReadCountBean);
+ return null;
+ }
+}
diff --git a/web/src/views/business/operationLog/operationLogList.vue b/web/src/views/business/operationLog/operationLogList.vue
index 6209ab4..d34120a 100644
--- a/web/src/views/business/operationLog/operationLogList.vue
+++ b/web/src/views/business/operationLog/operationLogList.vue
@@ -83,6 +83,17 @@
+
+
+
+ {{ scope.row.createTime }}
+
+
+
-
-
- {{ scope.row.createTime }}
-
-
diff --git a/web/src/views/common/Im.vue b/web/src/views/common/Im.vue
index bf9d69c..a426bbc 100644
--- a/web/src/views/common/Im.vue
+++ b/web/src/views/common/Im.vue
@@ -82,7 +82,6 @@
});
this.contact = contact
contact.page = 1
- contact.chatList = []
//读取当前用户信息
this.readAuthorMessage(contact.id)
//获取总未读消息
@@ -140,8 +139,6 @@
//倒序查询但是正序排列 时间早的在前面
this.contact.totalPage = res.data.pages
const messages = res.data.records
-
- this.contact.chatList.push(... res.data.records.reverse());
//当前页数小于等于总页数
if(this.contact.page<=res.data.pages){
//等于1时执行页面滚动操作