Commit 90504097 by Future

会话列表

parent 3d865a7b
...@@ -103,7 +103,6 @@ public class NormalChatAction { ...@@ -103,7 +103,6 @@ public class NormalChatAction {
} }
// 查询发送者client // 查询发送者client
ImClient imClientSender = ehcacheService.getEhCacheClient(request.getSenderClientId()); ImClient imClientSender = ehcacheService.getEhCacheClient(request.getSenderClientId());
log.info("imClientSender {}", JSON.toJSONString(imClientSender));
if (imClientSender == null) { if (imClientSender == null) {
log.warn("根据senderClientId: {} 查找不到 imClientSender!", request.getSenderClientId()); log.warn("根据senderClientId: {} 查找不到 imClientSender!", request.getSenderClientId());
return; return;
...@@ -128,8 +127,8 @@ public class NormalChatAction { ...@@ -128,8 +127,8 @@ public class NormalChatAction {
} }
Map<Long, ImConversationMembers> memberMap = membersList.stream().collect(Collectors.toMap(ImConversationMembers::getFkClientId, member -> member)); 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())) { if (black(reqId, imClientSender, membersList, request.getSenderChannel())) {
return; return;
......
...@@ -48,7 +48,7 @@ public interface ImConversationMapper extends BaseMapper<ImConversation> { ...@@ -48,7 +48,7 @@ public interface ImConversationMapper extends BaseMapper<ImConversation> {
* @param currentClientId * @param currentClientId
* @return * @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 ...@@ -829,12 +829,16 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
try { try {
// 获取当前client // 获取当前client
ImClient currentClient = contextService.getImClientIfNotNullOrThrow(); 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()) { if (myImConversationListAndMsgCount.isEmpty()) {
return Collections.emptyList(); return Collections.emptyList();
} }
// 根据top进行排序 // 根据top进行排序
List<ConversationVo> topList = myImConversationListAndMsgCount.stream().filter(ConversationVo::getTop).collect(Collectors.toList()); List<ConversationVo> topList = myImConversationListAndMsgCount.stream().filter(ConversationVo::getTop).collect(Collectors.toList());
List<ConversationVo> normalList = List<ConversationVo> normalList =
...@@ -845,13 +849,15 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -845,13 +849,15 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
// 最后返回的 // 最后返回的
List<ConversationVo> conversationListToReturn = new ArrayList<>(); List<ConversationVo> conversationListToReturn = new ArrayList<>();
List<ConversationCountVo> conversationCountVos = inboxService.countNotRead(currentClient.getId());
// 未读消息map
Map<Long, Integer> notReadMap = Maps.newHashMap(); Map<Long, Integer> notReadMap = Maps.newHashMap();
if (CollectionUtils.isNotEmpty(conversationCountVos)) { if (CollectionUtils.isNotEmpty(conversationCountVos)) {
for (ConversationCountVo conversationCountVo : conversationCountVos) { for (ConversationCountVo conversationCountVo : conversationCountVos) {
notReadMap.put(conversationCountVo.getConversationId(), conversationCountVo.getCount()); notReadMap.put(conversationCountVo.getConversationId(), conversationCountVo.getCount());
} }
} }
// 被@map
List<ConversationCountVo> beAtCountVos = inboxService.countBeAt(currentClient); List<ConversationCountVo> beAtCountVos = inboxService.countBeAt(currentClient);
Map<Long, Integer> beAtCountMap = Maps.newHashMap(); Map<Long, Integer> beAtCountMap = Maps.newHashMap();
if (CollectionUtils.isNotEmpty(beAtCountVos)) { if (CollectionUtils.isNotEmpty(beAtCountVos)) {
...@@ -914,7 +920,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -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)) { if (CollectionUtils.isEmpty(conversationList)) {
return null; return null;
} }
......
...@@ -53,8 +53,11 @@ ...@@ -53,8 +53,11 @@
INNER JOIN im_client ON im_client.id = imConversation.creator INNER JOIN im_client ON im_client.id = imConversation.creator
WHERE imConversationMembers.fk_client_id = #{currentClientId} WHERE imConversationMembers.fk_client_id = #{currentClientId}
AND imConversationMembers.display_status = 1 AND imConversationMembers.display_status = 1
<if test="conversationId != null"> <if test="conversationIds != null and conversationIds.size() > 0">
AND imConversation.id = #{conversationId} AND imConversation.id in
<foreach collection="conversationIds" item="conversationId" index="index" open="(" close=")" separator=",">
#{conversationId}
</foreach>
</if> </if>
GROUP BY imConversation.id) t GROUP BY imConversation.id) t
order by t.update_time desc 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