From 50b248d392d3496737eefe2f5dcc923d5e0c6ec3 Mon Sep 17 00:00:00 2001 From: mataoxun <2359971480@qq.com> Date: Sun, 19 Dec 2021 17:25:40 +0800 Subject: [PATCH] Last --- .../com/ruoyi/chat/LongConnection/handler/LogHandler.java | 2 +- .../handler/nettyService/HasChannelChatService.java | 2 +- .../handler/nettyService/NonChannelChatService.java | 2 +- .../java/com/ruoyi/chat/controller/InitController.java | 7 ++----- .../java/com/ruoyi/chat/service/impl/ChatServiceImpl.java | 4 +++- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/mobile-app/src/main/java/com/ruoyi/chat/LongConnection/handler/LogHandler.java b/mobile-app/src/main/java/com/ruoyi/chat/LongConnection/handler/LogHandler.java index 9f60c04..4359754 100644 --- a/mobile-app/src/main/java/com/ruoyi/chat/LongConnection/handler/LogHandler.java +++ b/mobile-app/src/main/java/com/ruoyi/chat/LongConnection/handler/LogHandler.java @@ -42,7 +42,7 @@ public class LogHandler extends SimpleChannelInboundHandler } //添加连接 LongConnectionUtil.add(loginDTO.getSenderId(), (SocketChannel)ctx.channel()); - ctx.writeAndFlush(LongConnectionMsgUtil.ObjectToWSTextResult(new ReturnMsgVo(ReturnMsgVo.LOG_SUCCESS,"成功登录"))); + ctx.writeAndFlush(LongConnectionMsgUtil.ObjectToWSTextResult(new ReturnMsgVo(ReturnMsgVo.LOG_SUCCESS,loginDTO.getSenderId()+"成功登录"))); msg.release(); } diff --git a/mobile-app/src/main/java/com/ruoyi/chat/LongConnection/handler/nettyService/HasChannelChatService.java b/mobile-app/src/main/java/com/ruoyi/chat/LongConnection/handler/nettyService/HasChannelChatService.java index bfede82..b27beac 100644 --- a/mobile-app/src/main/java/com/ruoyi/chat/LongConnection/handler/nettyService/HasChannelChatService.java +++ b/mobile-app/src/main/java/com/ruoyi/chat/LongConnection/handler/nettyService/HasChannelChatService.java @@ -71,9 +71,9 @@ public class HasChannelChatService { })); map.put(LongConnectionChatDTO.FILE, ((ctx, chatDTO, senderId) -> { - ChatRecord chatrecord = ChatRecord.ChatRecordReaded(senderId, chatDTO.getReceiverId(), "", chatDTO.getMsgType()); FileMsg fileMsg = mapper.convertValue(chatDTO.getMessage(), FileMsg.class); String url = mclass.minioService.setFile(fileMsg); + ChatRecord chatrecord = ChatRecord.ChatRecordReaded(senderId, chatDTO.getReceiverId(), url+"_mtx_"+fileMsg.getFileName(), chatDTO.getMsgType()); mclass.chatrecordService.save(chatrecord); ChatFileData ChatFileData = new ChatFileData(chatrecord.getMsgId(), url, fileMsg.getFileName()); diff --git a/mobile-app/src/main/java/com/ruoyi/chat/LongConnection/handler/nettyService/NonChannelChatService.java b/mobile-app/src/main/java/com/ruoyi/chat/LongConnection/handler/nettyService/NonChannelChatService.java index f6b7ebe..9315f63 100644 --- a/mobile-app/src/main/java/com/ruoyi/chat/LongConnection/handler/nettyService/NonChannelChatService.java +++ b/mobile-app/src/main/java/com/ruoyi/chat/LongConnection/handler/nettyService/NonChannelChatService.java @@ -62,7 +62,7 @@ public class NonChannelChatService { map.put(LongConnectionChatDTO.FILE, ((ctx, chatDTO, senderId) -> { FileMsg fileMsg = mapper.convertValue(chatDTO.getMessage(), FileMsg.class); String url = mclass.minioService.setFile(fileMsg); - ChatRecord chatrecord = ChatRecord.ChatRecordUnRead(senderId, chatDTO.getReceiverId(), "", chatDTO.getMsgType()); + ChatRecord chatrecord = ChatRecord.ChatRecordUnRead(senderId, chatDTO.getReceiverId(), url+"_mtx_"+fileMsg.getFileName(), chatDTO.getMsgType()); mclass.chatrecordService.save(chatrecord); ChatFileData ChatFileData = new ChatFileData(chatrecord.getMsgId(), url, fileMsg.getFileName()); mclass.ChatFileDataService.save(ChatFileData); diff --git a/mobile-app/src/main/java/com/ruoyi/chat/controller/InitController.java b/mobile-app/src/main/java/com/ruoyi/chat/controller/InitController.java index 8fb376c..62bc3ad 100644 --- a/mobile-app/src/main/java/com/ruoyi/chat/controller/InitController.java +++ b/mobile-app/src/main/java/com/ruoyi/chat/controller/InitController.java @@ -4,10 +4,7 @@ import com.ruoyi.chat.model.vo.MessageVo; import com.ruoyi.chat.service.IChatService; import com.ruoyi.chat.util.MapperUtil; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -44,7 +41,7 @@ public class InitController { * @author MaTaoxun * @date 2021/10/2 19:27 */ - @GetMapping("/InitHistoryChats") + @PostMapping("/InitHistoryChats") public List InitHistoryChats(@RequestBody String id){ return MapperUtil.copyObjects(chatService.getAllFriendsThreeHistoryChats(id), MessageVo.class); } diff --git a/mobile-app/src/main/java/com/ruoyi/chat/service/impl/ChatServiceImpl.java b/mobile-app/src/main/java/com/ruoyi/chat/service/impl/ChatServiceImpl.java index 610b51f..32cdf26 100644 --- a/mobile-app/src/main/java/com/ruoyi/chat/service/impl/ChatServiceImpl.java +++ b/mobile-app/src/main/java/com/ruoyi/chat/service/impl/ChatServiceImpl.java @@ -47,6 +47,8 @@ public class ChatServiceImpl implements IChatService { QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq("if_read", "F").eq("receiver_id", id).select("receiver_id", "sender_id", "message", "msg_type", "rb", "CREATED_TIME", "msg_id").orderByAsc("CREATED_TIME"); List list = chatrecordService.list(wrapper); + List readedList = list.stream().map(c -> c.setIfRead("T")).collect(Collectors.toList()); + chatrecordService.updateBatchById(readedList); return list; } @@ -75,7 +77,7 @@ public class ChatServiceImpl implements IChatService { public void run() { QueryWrapper wrapper1 = new QueryWrapper<>(); wrapper1.eq("receiver_id", item).and(i -> i.eq("sender_id", id)).or().eq("sender_id", item).and(i -> i.eq("receiver_id", id)). - select("receiver_id", "sender_id", "message", "msg_type", "rb", "CREATED_TIME", "msg_id").orderByDesc("CREATED_TIME").last("limit 3"); + select("receiver_id", "sender_id", "message", "msg_type", "rb", "CREATED_TIME", "msg_id").orderByDesc("CREATED_TIME").last("limit 10"); List list = chatrecordService.list(wrapper1); rs.addAll(list); latch.countDown(); -- Gitee