update 重构分页工具 使用分页实体类 过期方法标注过期 3.6.0 移除
This commit is contained in:
parent
8d2886e1ca
commit
b5db6fe186
@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.PagePlus;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.utils.sql.SqlUtil;
|
||||
@ -20,21 +21,25 @@ public class PageUtils {
|
||||
/**
|
||||
* 当前记录起始索引
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PAGE_NUM = "pageNum";
|
||||
|
||||
/**
|
||||
* 每页显示记录数
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PAGE_SIZE = "pageSize";
|
||||
|
||||
/**
|
||||
* 排序列
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String ORDER_BY_COLUMN = "orderByColumn";
|
||||
|
||||
/**
|
||||
* 排序的方向 "desc" 或者 "asc".
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String IS_ASC = "isAsc";
|
||||
|
||||
/**
|
||||
@ -53,7 +58,10 @@ public class PageUtils {
|
||||
* @param <T> domain 实体
|
||||
* @param <K> vo 实体
|
||||
* @return 分页对象
|
||||
* @deprecated 3.6.0 删除 请使用 {@link PageUtils#buildPagePlus(PageQuery)}
|
||||
* 由于使用 Servlet 获取只能从 param 获取 灵活性降低 故将传参操作交给用户
|
||||
*/
|
||||
@Deprecated
|
||||
public static <T, K> PagePlus<T, K> buildPagePlus() {
|
||||
Integer pageNum = ServletUtils.getParameterToInt(PAGE_NUM, DEFAULT_PAGE_NUM);
|
||||
Integer pageSize = ServletUtils.getParameterToInt(PAGE_SIZE, DEFAULT_PAGE_SIZE);
|
||||
@ -70,6 +78,23 @@ public class PageUtils {
|
||||
return page;
|
||||
}
|
||||
|
||||
public static <T, K> PagePlus<T, K> buildPagePlus(PageQuery pageQuery) {
|
||||
Integer pageNum = ObjectUtil.defaultIfNull(pageQuery.getPageNum(), DEFAULT_PAGE_NUM);
|
||||
Integer pageSize = ObjectUtil.defaultIfNull(pageQuery.getPageSize(), DEFAULT_PAGE_SIZE);
|
||||
String orderByColumn = pageQuery.getOrderByColumn();
|
||||
String isAsc = pageQuery.getIsAsc();
|
||||
if (pageNum <= 0) {
|
||||
pageNum = DEFAULT_PAGE_NUM;
|
||||
}
|
||||
PagePlus<T, K> page = new PagePlus<>(pageNum, pageSize);
|
||||
OrderItem orderItem = buildOrderItem(orderByColumn, isAsc);
|
||||
if (ObjectUtil.isNotNull(orderItem)) {
|
||||
page.addOrder(orderItem);
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static <T> Page<T> buildPage() {
|
||||
return buildPage(null, null);
|
||||
}
|
||||
@ -79,7 +104,10 @@ public class PageUtils {
|
||||
*
|
||||
* @param <T> domain 实体
|
||||
* @return 分页对象
|
||||
* @deprecated 3.6.0 删除 请使用 {@link PageUtils#buildPage(PageQuery)}
|
||||
* 由于使用 Servlet 获取只能从 param 获取 灵活性降低 故将传参操作交给用户
|
||||
*/
|
||||
@Deprecated
|
||||
public static <T> Page<T> buildPage(String defaultOrderByColumn, String defaultIsAsc) {
|
||||
Integer pageNum = ServletUtils.getParameterToInt(PAGE_NUM, DEFAULT_PAGE_NUM);
|
||||
Integer pageSize = ServletUtils.getParameterToInt(PAGE_SIZE, DEFAULT_PAGE_SIZE);
|
||||
@ -96,6 +124,23 @@ public class PageUtils {
|
||||
return page;
|
||||
}
|
||||
|
||||
public static <T> Page<T> buildPage(PageQuery pageQuery) {
|
||||
Integer pageNum = ObjectUtil.defaultIfNull(pageQuery.getPageNum(), DEFAULT_PAGE_NUM);
|
||||
Integer pageSize = ObjectUtil.defaultIfNull(pageQuery.getPageSize(), DEFAULT_PAGE_SIZE);
|
||||
String orderByColumn = pageQuery.getOrderByColumn();
|
||||
String isAsc = pageQuery.getIsAsc();
|
||||
if (pageNum <= 0) {
|
||||
pageNum = DEFAULT_PAGE_NUM;
|
||||
}
|
||||
Page<T> page = new Page<>(pageNum, pageSize);
|
||||
OrderItem orderItem = buildOrderItem(orderByColumn, isAsc);
|
||||
if (ObjectUtil.isNotNull(orderItem)) {
|
||||
page.addOrder(orderItem);
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
private static OrderItem buildOrderItem(String orderByColumn, String isAsc) {
|
||||
// 兼容前端排序类型
|
||||
if ("ascending".equals(isAsc)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user