Commit 90504097 by Future

会话列表

parent 3d865a7b
......@@ -103,7 +103,6 @@ public class NormalChatAction {
}
// 查询发送者client
ImClient imClientSender = ehcacheService.getEhCacheClient(request.getSenderClientId());
log.info("imClientSender {}", JSON.toJSONString(imClientSender));
if (imClientSender == null) {
log.warn("根据senderClientId: {} 查找不到 imClientSender!", request.getSenderClientId());
return;
......@@ -128,8 +127,8 @@ public class NormalChatAction {
}
Map<Long, ImConversationMembers> memberMap = membersList.stream().collect(Collectors.toMap(ImConversationMembers::getFkClientId, member -> member));
// 判断为单聊
if (ChatTypeEnum.SINGLE.getCode().equals(conversation.getChatType()) || ChatTypeEnum.TEMP.getCode().equals(conversation.getChatType())) {
// 判断为单聊 只能用成员数量来判断,不可用枚举,还需考虑系统消息,临时消息等
if (membersList.size() == 2) {
// 判断是否被拉黑逻辑
if (black(reqId, imClientSender, membersList, request.getSenderChannel())) {
return;
......
......@@ -48,7 +48,7 @@ public interface ImConversationMapper extends BaseMapper<ImConversation> {
* @param currentClientId
* @return
*/
List<ConversationVo> getMyImConversationListAndMsgCount(@Param("currentClientId") Long currentClientId, @Param("conversationId") Long conversationId);
List<ConversationVo> getMyImConversationListAndMsgCount(@Param("currentClientId") Long currentClientId, @Param("conversationIds") List<Long> conversationIds);
/**
* 查询用户加入的所有会话
......
......@@ -829,12 +829,16 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
try {
// 获取当前client
ImClient currentClient = contextService.getImClientIfNotNullOrThrow();
// 查询用户加入的所有会话 与每个会话的未读条数 成员
List<ConversationVo> myImConversationListAndMsgCount = imConversationMapper.getMyImConversationListAndMsgCount(currentClient.getId(), null);
// 查询用户加入的有未读消息的会话列表
List<ConversationCountVo> conversationCountVos = inboxService.countNotRead(currentClient.getId());
List<Long> conversationIds = conversationCountVos.stream().map(ConversationCountVo::getConversationId).collect(Collectors.toList());;
if (CollectionUtils.isEmpty(conversationIds)) {
return Lists.newArrayList();
}
List<ConversationVo> myImConversationListAndMsgCount = imConversationMapper.getMyImConversationListAndMsgCount(currentClient.getId(), conversationIds);
if (myImConversationListAndMsgCount.isEmpty()) {
return Collections.emptyList();
}
// 根据top进行排序
List<ConversationVo> topList = myImConversationListAndMsgCount.stream().filter(ConversationVo::getTop).collect(Collectors.toList());
List<ConversationVo> normalList =
......@@ -845,13 +849,15 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
// 最后返回的
List<ConversationVo> conversationListToReturn = new ArrayList<>();
List<ConversationCountVo> conversationCountVos = inboxService.countNotRead(currentClient.getId());
// 未读消息map
Map<Long, Integer> notReadMap = Maps.newHashMap();
if (CollectionUtils.isNotEmpty(conversationCountVos)) {
for (ConversationCountVo conversationCountVo : conversationCountVos) {
notReadMap.put(conversationCountVo.getConversationId(), conversationCountVo.getCount());
}
}
// 被@map
List<ConversationCountVo> beAtCountVos = inboxService.countBeAt(currentClient);
Map<Long, Integer> beAtCountMap = Maps.newHashMap();
if (CollectionUtils.isNotEmpty(beAtCountVos)) {
......@@ -914,7 +920,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
}
}
// 查询用户加入的所有会话 与每个会话的未读条数 成员
List<ConversationVo> conversationList = imConversationMapper.getMyImConversationListAndMsgCount(client.getId(), param.getId());
List<ConversationVo> conversationList = imConversationMapper.getMyImConversationListAndMsgCount(client.getId(), Lists.newArrayList(param.getId()));
if (CollectionUtils.isEmpty(conversationList)) {
return null;
}
......
......@@ -53,8 +53,11 @@
INNER JOIN im_client ON im_client.id = imConversation.creator
WHERE imConversationMembers.fk_client_id = #{currentClientId}
AND imConversationMembers.display_status = 1
<if test="conversationId != null">
AND imConversation.id = #{conversationId}
<if test="conversationIds != null and conversationIds.size() > 0">
AND imConversation.id in
<foreach collection="conversationIds" item="conversationId" index="index" open="(" close=")" separator=",">
#{conversationId}
</foreach>
</if>
GROUP BY imConversation.id) t
order by t.update_time desc
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment