优化查询sql 小程序未读消息数量通过websocket获取

This commit is contained in:
wxl 2025-01-12 23:55:59 +08:00
parent 5bb4ecc25a
commit 413cc421a8
4 changed files with 63 additions and 14 deletions

View File

@ -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,

View File

@ -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;
}
}

View File

@ -83,6 +83,17 @@
</template>
</el-table-column>
<el-table-column
label="操作时间"
width="160"
align="center"
>
<template slot-scope="scope">
{{ scope.row.createTime }}
</template>
</el-table-column>
<el-table-column
label="请求模块"
width="160"
@ -165,15 +176,6 @@
</template>
</el-table-column>
<el-table-column
label="操作时间"
width="160"
align="center"
>
<template slot-scope="scope">
{{ scope.row.createTime }}
</template>
</el-table-column>

View File

@ -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