Sfoglia il codice sorgente

获取当前用户的返图记录增加分页

fangqing 4 mesi fa
parent
commit
3be652bb33

+ 4 - 1
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityChatMsgController.java

@@ -255,12 +255,15 @@ public class CommunityChatMsgController extends BaseController {
     @GetMapping("/getReturnRecord")
     public AjaxResult getReturnRecord(String status, String searchValue) {
         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<CommunityReturnRecord> returnRecords = communityReturnRecordService
                 .getReturnRecord(userId, status);
         if (returnRecords != null && !returnRecords.isEmpty()) {
             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);
         }
         return AjaxResult.success(sysUserChatVos);
     }

+ 3 - 1
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,
                                          @Param("type") String type,
                                          @Param("searchValue") String searchValue,
-                                         @Param("returnRecordIds")  List<Long> returnRecordIds);
+                                         @Param("returnRecordIds")  List<Long> returnRecordIds,
+                                         @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
      * @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 返图聊天列表
      */
     @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);
     }
 }

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

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