集成websocket 未读提示
This commit is contained in:
@@ -8,6 +8,7 @@ import com.dd.admin.business.author.entity.Author;
|
|||||||
import com.dd.admin.business.author.service.AuthorService;
|
import com.dd.admin.business.author.service.AuthorService;
|
||||||
import com.dd.admin.business.chat.domain.ChatDto;
|
import com.dd.admin.business.chat.domain.ChatDto;
|
||||||
import com.dd.admin.business.chat.domain.ChatVo;
|
import com.dd.admin.business.chat.domain.ChatVo;
|
||||||
|
import com.dd.admin.business.chat.entity.Chat;
|
||||||
import com.dd.admin.business.chat.service.ChatService;
|
import com.dd.admin.business.chat.service.ChatService;
|
||||||
import com.dd.admin.business.file.entity.File;
|
import com.dd.admin.business.file.entity.File;
|
||||||
import com.dd.admin.business.file.service.FileService;
|
import com.dd.admin.business.file.service.FileService;
|
||||||
@@ -641,4 +642,24 @@ public class AuthApi {
|
|||||||
return ResultBean.success(chatVos);
|
return ResultBean.success(chatVos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "读取消息")
|
||||||
|
@ApiOperationSupport(order = 1)
|
||||||
|
@PostMapping("/api/auth/readAuthorMessage")
|
||||||
|
@OperLog(operModule = "读取消息",operType = OperType.OTHER,operDesc = "读取消息")
|
||||||
|
public ResultBean readAuthorMessage(String authorId) {
|
||||||
|
String loginId = String.valueOf(request.getAttribute("authorId"));
|
||||||
|
chatService.readMessage(authorId,loginId);
|
||||||
|
return ResultBean.success(loginId);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(value = "查询我的未读消息数量")
|
||||||
|
@ApiOperationSupport(order = 1)
|
||||||
|
@GetMapping("/api/auth/getUnReadCount")
|
||||||
|
@OperLog(operModule = "查询我的未读消息数量",operType = OperType.OTHER,operDesc = "查询我的未读消息数量")
|
||||||
|
public ResultBean getUnReadCount() {
|
||||||
|
String loginId = String.valueOf(request.getAttribute("authorId"));
|
||||||
|
Integer unReadCount = chatService.selectUnReadCount(loginId);
|
||||||
|
return ResultBean.success(unReadCount);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@@ -78,4 +78,5 @@ public class ChatVo {
|
|||||||
private String authorId;
|
private String authorId;
|
||||||
private String authorName;
|
private String authorName;
|
||||||
private String authorAvatar;
|
private String authorAvatar;
|
||||||
|
private String unReadCount;
|
||||||
}
|
}
|
||||||
|
@@ -66,7 +66,17 @@
|
|||||||
a.FROM_NAME AS authorName,
|
a.FROM_NAME AS authorName,
|
||||||
b.AVATAR_URL AS authorAvatar,
|
b.AVATAR_URL AS authorAvatar,
|
||||||
a.content,
|
a.content,
|
||||||
a.create_time
|
a.create_time,
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
count(1)
|
||||||
|
FROM
|
||||||
|
business_chat ca
|
||||||
|
WHERE
|
||||||
|
ca.FROM_ID = a.FROM_ID
|
||||||
|
AND ca.to_id = #{authorId}
|
||||||
|
and ca.MESSAGE_STATUS = 0
|
||||||
|
) as unReadCount
|
||||||
FROM
|
FROM
|
||||||
business_chat a
|
business_chat a
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
@@ -79,7 +89,8 @@
|
|||||||
a.TO_NAME AS authorName,
|
a.TO_NAME AS authorName,
|
||||||
b.AVATAR_URL AS authorAvatar,
|
b.AVATAR_URL AS authorAvatar,
|
||||||
a.content,
|
a.content,
|
||||||
a.create_time
|
a.create_time,
|
||||||
|
0 as unReadCount
|
||||||
FROM
|
FROM
|
||||||
business_chat a
|
business_chat a
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
|
@@ -26,4 +26,6 @@ public interface ChatService extends IService<Chat> {
|
|||||||
List<ChatVo> selectChatDetail(ChatDto chatDto);
|
List<ChatVo> selectChatDetail(ChatDto chatDto);
|
||||||
List<ChatVo> selectChatList(String authorId);
|
List<ChatVo> selectChatList(String authorId);
|
||||||
|
|
||||||
|
void readMessage(String authorId,String loginId);
|
||||||
|
Integer selectUnReadCount(String authorId);
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,8 @@
|
|||||||
package com.dd.admin.business.chat.service.impl;
|
package com.dd.admin.business.chat.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.dd.admin.common.model.PageFactory;
|
import com.dd.admin.common.model.PageFactory;
|
||||||
@@ -43,4 +46,21 @@ public class ChatServiceImpl extends ServiceImpl<ChatMapper, Chat> implements Ch
|
|||||||
public List<ChatVo> selectChatList(String authorId) {
|
public List<ChatVo> selectChatList(String authorId) {
|
||||||
return baseMapper.selectChatList(authorId);
|
return baseMapper.selectChatList(authorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readMessage(String authorId, String loginId) {
|
||||||
|
LambdaUpdateWrapper<Chat> queryWrapper = new LambdaUpdateWrapper();
|
||||||
|
queryWrapper.eq(Chat::getFromId,authorId);
|
||||||
|
queryWrapper.eq(Chat::getToId,loginId);
|
||||||
|
queryWrapper.set(Chat::getMessageStatus,1);
|
||||||
|
this.update(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer selectUnReadCount(String authorId) {
|
||||||
|
LambdaQueryWrapper<Chat> queryWrapper = new LambdaQueryWrapper();
|
||||||
|
queryWrapper.eq(Chat::getToId,authorId);
|
||||||
|
queryWrapper.eq(Chat::getMessageStatus,0);
|
||||||
|
return baseMapper.selectCount(queryWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1 +1 @@
|
|||||||
package com.dd.admin.business.webSocket.handler;
|
package com.dd.admin.business.webSocket.handler;
|
Reference in New Issue
Block a user