Przeglądaj źródła

Merge branch 'master' into dev

# Conflicts:
#	ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityChatMsgController.java
fangqing 3 miesięcy temu
rodzic
commit
bc4eb09a95

+ 13 - 2
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityChatMsgController.java

@@ -5,8 +5,11 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.core.text.Convert;
 import com.ruoyi.common.exception.user.ProjectException;
 import com.ruoyi.common.exception.user.ProjectException;
+import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.ServletUtils;
 import com.ruoyi.common.utils.bean.BeanUtils;
 import com.ruoyi.common.utils.bean.BeanUtils;
 import com.ruoyi.generator.domain.Community.CommunityReturnRecord;
 import com.ruoyi.generator.domain.Community.CommunityReturnRecord;
 import com.ruoyi.generator.domain.Community.CommunityUserBlock;
 import com.ruoyi.generator.domain.Community.CommunityUserBlock;
@@ -62,6 +65,11 @@ public class CommunityChatMsgController extends BaseController {
     public AjaxResult chatRecord(Long otherUserId, String type) {
     public AjaxResult chatRecord(Long otherUserId, String type) {
         Long userId = SecurityUtils.getUserId();
         Long userId = SecurityUtils.getUserId();
         List<CommunityChatMsgVo> chatMsgVos = new ArrayList<>();
         List<CommunityChatMsgVo> chatMsgVos = new ArrayList<>();
+        int pageNum = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
+        int pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
+        int offset = (pageNum - 1) * pageSize;
+
+
         try {
         try {
             List<CommunityUserBlock> communityUserBlocks = communityUserBlockMapper.selectList(new QueryWrapper<CommunityUserBlock>()
             List<CommunityUserBlock> communityUserBlocks = communityUserBlockMapper.selectList(new QueryWrapper<CommunityUserBlock>()
                     .eq("user_id", userId)
                     .eq("user_id", userId)
@@ -84,7 +92,7 @@ public class CommunityChatMsgController extends BaseController {
                     })
                     })
                     .orderByDesc("create_time")
                     .orderByDesc("create_time")
             );*/
             );*/
-            List<CommunityChatMsg> chatMsgList = communitychatMsgMapper.getChatMsgRecord(userId, otherUserId, type);
+            List<CommunityChatMsg> chatMsgList = communitychatMsgMapper.getChatMsgRecord(userId, otherUserId, type,offset,pageSize);
 
 
             //更新该消息标记为已读
             //更新该消息标记为已读
             List<Long> msgId = chatMsgList.stream()
             List<Long> msgId = chatMsgList.stream()
@@ -250,12 +258,15 @@ public class CommunityChatMsgController extends BaseController {
     @GetMapping("/getReturnRecord")
     @GetMapping("/getReturnRecord")
     public AjaxResult getReturnRecord(String status, String searchValue) {
     public AjaxResult getReturnRecord(String status, String searchValue) {
         Long userId = SecurityUtils.getUserId();
         Long userId = SecurityUtils.getUserId();
+        int pageNum = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
+        int pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
+        int offset = (pageNum - 1) * pageSize;
         List<SysUserVo> sysUserChatVos = null;
         List<SysUserVo> sysUserChatVos = null;
         List<CommunityReturnRecord> returnRecords = communityReturnRecordService
         List<CommunityReturnRecord> returnRecords = communityReturnRecordService
                 .getReturnRecord(userId, status);
                 .getReturnRecord(userId, status);
         if (returnRecords != null && !returnRecords.isEmpty()) {
         if (returnRecords != null && !returnRecords.isEmpty()) {
             List<Long> returnIds = returnRecords.stream().map(CommunityReturnRecord::getId).collect(Collectors.toList());
             List<Long> returnIds = returnRecords.stream().map(CommunityReturnRecord::getId).collect(Collectors.toList());
-            sysUserChatVos = communityChatMsgService.getChatListWithLatestMessage(userId, "anonymous", searchValue, returnIds);
+            sysUserChatVos = communityChatMsgService.getChatListWithLatestMessage(userId, "anonymous", searchValue, returnIds,offset,pageSize);
             if (!sysUserChatVos.isEmpty()) {
             if (!sysUserChatVos.isEmpty()) {
                 for (SysUserVo sysUserChatVo : sysUserChatVos) {
                 for (SysUserVo sysUserChatVo : sysUserChatVos) {
                     CommunityReturnRecord returnRecord = communityReturnRecordService.getOne(new QueryWrapper<CommunityReturnRecord>().eq("id", sysUserChatVo.getReturnRecordId()));
                     CommunityReturnRecord returnRecord = communityReturnRecordService.getOne(new QueryWrapper<CommunityReturnRecord>().eq("id", sysUserChatVo.getReturnRecordId()));

+ 6 - 2
ruoyi-system/src/main/java/com/ruoyi/system/mapper/CommunityChatMsgMapper.java

@@ -28,7 +28,9 @@ public interface CommunityChatMsgMapper extends BaseMapper<CommunityChatMsg> {
     List<SysUserVo> getReturnChatMessage(@Param("userId") Long userId,
     List<SysUserVo> getReturnChatMessage(@Param("userId") Long userId,
                                          @Param("type") String type,
                                          @Param("type") String type,
                                          @Param("searchValue") String searchValue,
                                          @Param("searchValue") String searchValue,
-                                         @Param("returnRecordIds")  List<Long> returnRecordIds);
+                                         @Param("returnRecordIds")  List<Long> returnRecordIds,
+                                         @Param("offset") int offset,
+                                         @Param("limit") int limit);
 
 
     /**
     /**
      * 获取登录用户聊天记录
      * 获取登录用户聊天记录
@@ -40,5 +42,7 @@ public interface CommunityChatMsgMapper extends BaseMapper<CommunityChatMsg> {
      */
      */
     List<CommunityChatMsg> getChatMsgRecord(@Param("userId") Long userId,
     List<CommunityChatMsg> getChatMsgRecord(@Param("userId") Long userId,
                                             @Param("otherUserId") Long otherUserId,
                                             @Param("otherUserId") Long otherUserId,
-                                            @Param("type") String type);
+                                            @Param("type") String type,
+                                            @Param("offset") int offset,
+                                            @Param("limit") int limit);
 }
 }

+ 2 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/ICommunityChatMsgService.java

@@ -23,5 +23,6 @@ public interface ICommunityChatMsgService extends IService<CommunityChatMsg> {
      * @param userId 用户id
      * @param userId 用户id
      * @return 用户聊天列表
      * @return 用户聊天列表
      */
      */
-    List<SysUserVo> getChatListWithLatestMessage(Long userId, String type, String searchValue, List<Long> returnRecordIds);
+    List<SysUserVo> getChatListWithLatestMessage(Long userId, String type, String searchValue, List<Long> returnRecordIds,int offset,int limit);
+
 }
 }

+ 2 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CommunityChatMsgServiceImpl.java

@@ -36,7 +36,7 @@ public class CommunityChatMsgServiceImpl extends ServiceImpl<CommunityChatMsgMap
      * @return 返图聊天列表
      * @return 返图聊天列表
      */
      */
     @Override
     @Override
-    public List<SysUserVo> getChatListWithLatestMessage(Long userId, String type, String searchValue, List<Long> returnRecordIds) {
-        return communityChatMsgMapper.getReturnChatMessage(userId, type, searchValue, returnRecordIds);
+    public List<SysUserVo> getChatListWithLatestMessage(Long userId, String type, String searchValue, List<Long> returnRecordIds,int offset,int limit) {
+        return communityChatMsgMapper.getReturnChatMessage(userId, type, searchValue, returnRecordIds,offset,limit);
     }
     }
 }
 }

+ 3 - 1
ruoyi-system/src/main/resources/mapper/system/CommunityChatMsgMapper.xml

@@ -145,7 +145,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT *
         SELECT *
         FROM RankedMessages
         FROM RankedMessages
         WHERE rn = 1
         WHERE rn = 1
-        ORDER BY msgTime DESC;
+        ORDER BY msgTime DESC
+        limit #{offset},#{limit};
     </select>
     </select>
 
 
     <select id="getChatMsgRecord" resultType="com.ruoyi.system.domain.CommunityChatMsg">
     <select id="getChatMsgRecord" resultType="com.ruoyi.system.domain.CommunityChatMsg">
@@ -195,5 +196,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 )
                 )
             )
             )
         ORDER BY create_time DESC
         ORDER BY create_time DESC
+        limit #{offset},#{limit}
     </select>
     </select>
 </mapper>
 </mapper>