|
@@ -148,7 +148,13 @@ public class ChatSessionServiceImpl extends ServiceImpl<ChatSessionMapper, ChatS
|
|
|
RoomInfo roomInfo = Optional.ofNullable(JSONObject.parseObject(redis.get("ROOM:" + entity.getSessionid()), RoomInfo.class)).orElseGet(() -> {
|
|
|
RoomInfo roomInfo1 = new RoomInfo();
|
|
|
List<ChatMsgEntity> msgList = msgService.list(new QueryWrapper<ChatMsgEntity>().eq("sessionid", entity.getSessionid()).last("order by create_time limit 1"));
|
|
|
- ChatMsgEntity lastMsg = Optional.ofNullable(msgList.get(0)).orElse(new ChatMsgEntity());
|
|
|
+ Optional<List<ChatMsgEntity>> msgListOption = Optional.ofNullable(msgList);
|
|
|
+ ChatMsgEntity lastMsg = null;
|
|
|
+ if (msgListOption.isPresent()){
|
|
|
+ lastMsg = msgListOption.get().get(0);
|
|
|
+ } else{
|
|
|
+ lastMsg = new ChatMsgEntity();
|
|
|
+ }
|
|
|
Long lastTimeStamp = Optional.ofNullable(lastMsg.getCreateTime()).map(localDateTime -> localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli()).orElse(null);
|
|
|
|
|
|
roomInfo1.setLastTime(lastTimeStamp);
|