Browse Source

朋友列表排序,防止redis中获取到的房间为空

udream-cxs 5 years ago
parent
commit
326ce081b4

+ 4 - 2
lift-ud-service/src/main/java/cn/com/ty/lift/ud/chat/service/impl/ChatSessionServiceImpl.java

@@ -135,8 +135,10 @@ public class ChatSessionServiceImpl extends ServiceImpl<ChatSessionMapper, ChatS
         List<ChatSessionEntity> list = sessionMapper.findDBListByUserId(query.getUserId());
         list.forEach(entity -> {
             RoomInfo roomInfo = redis.get("ROOM:" + entity.getSessionid(), RoomInfo.class);
-            entity.setLastMsg(roomInfo.getLastChat());
-            entity.setLastTime(roomInfo.getLastTime());
+            if (null != roomInfo){
+                entity.setLastMsg(roomInfo.getLastChat());
+                entity.setLastTime(roomInfo.getLastTime());
+            }
         });
         Collections.sort(list, (ent1, ent2) -> ent2.getLastTime().compareTo(ent1.getLastTime()));