|
@@ -3,6 +3,7 @@ package com.zhongzheng.common.core.controller;
|
|
import cn.hutool.core.lang.Validator;
|
|
import cn.hutool.core.lang.Validator;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.http.HttpStatus;
|
|
import cn.hutool.http.HttpStatus;
|
|
|
|
+import com.github.pagehelper.Page;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.zhongzheng.common.core.domain.AjaxResult;
|
|
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;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 响应请求分页数据
|
|
* 响应请求分页数据
|
|
*/
|
|
*/
|