Selaa lähdekoodia

fix 学习账号标记分页

tanzh 3 vuotta sitten
vanhempi
commit
8fe6e89900

+ 2 - 1
zhongzheng-admin/src/main/java/com/zhongzheng/controller/grade/ClassGradeController.java

@@ -10,6 +10,7 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil;
 import cn.afterturn.easypoi.excel.entity.ExportParams;
 import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
 import cn.hutool.core.lang.Validator;
+import com.github.pagehelper.PageInfo;
 import com.zhongzheng.common.core.redis.RedisCache;
 import com.zhongzheng.common.utils.SecurityUtils;
 import com.zhongzheng.common.utils.ServletUtils;
@@ -518,7 +519,7 @@ public class ClassGradeController extends BaseController {
     @GetMapping("/listStudyAccountStatus")
     public TableDataInfo<StudyAccountStatusVo> listStudyAccountStatus(StudyAccountStatusQueryBo bo) {
         List<StudyAccountStatusVo> list = iClassGradeUserService.listStudyAccountStatus(bo);
-        return getDataTable(list);
+        return getDataTable(getPageInfo(bo.getPageNum(), bo.getPageSize(), list).getList());
     }
 
     /**

+ 27 - 0
zhongzheng-common/src/main/java/com/zhongzheng/common/core/controller/BaseController.java

@@ -3,6 +3,7 @@ package com.zhongzheng.common.core.controller;
 import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HttpStatus;
+import com.github.pagehelper.Page;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.zhongzheng.common.core.domain.AjaxResult;
@@ -62,6 +63,32 @@ public class BaseController
         }
     }
 
+    /**
+     * pagehelper   手动分页
+     * @param currentPage 当前页
+     * @param pageSize
+     * @param list
+     * @param <T>
+     * @return
+     */
+    public static <T> PageInfo<T> getPageInfo(int currentPage, int pageSize, List<T> list) {
+        int total = list.size();
+        if (total > pageSize) {
+            int toIndex = pageSize * currentPage;
+            if (toIndex > total) {
+                toIndex = total;
+            }
+            list = list.subList(pageSize * (currentPage - 1), toIndex);
+        }
+        Page<T> page = new Page<>(currentPage, pageSize);
+        page.addAll(list);
+        page.setPages((total + pageSize - 1) / pageSize);
+        page.setTotal(total);
+
+        PageInfo<T> pageInfo = new PageInfo<>(page);
+        return pageInfo;
+    }
+
     /**
      * 响应请求分页数据
      */

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/ClassGradeUserServiceImpl.java

@@ -1747,9 +1747,9 @@ public class ClassGradeUserServiceImpl extends ServiceImpl<ClassGradeUserMapper,
         return list;
     }
 
+    @Override
     public List<ClassGradeUserGoodsVo> selectGoodsGradeList(Long goodsId) {
         return baseMapper.selectGoodsGradeList(goodsId);
-
     }