2021-12-18 12:22:41 +08:00
|
|
|
package com.ruoyi.common.utils;
|
|
|
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
import com.ruoyi.common.core.page.PageDomain;
|
|
|
|
import com.ruoyi.common.core.page.TableSupport;
|
|
|
|
import com.ruoyi.common.utils.sql.SqlUtil;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 分页工具类
|
|
|
|
*
|
|
|
|
* @author ruoyi
|
|
|
|
*/
|
|
|
|
public class PageUtils extends PageHelper
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* 设置请求分页数据
|
|
|
|
*/
|
|
|
|
public static void startPage()
|
|
|
|
{
|
|
|
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
|
|
|
Integer pageNum = pageDomain.getPageNum();
|
|
|
|
Integer pageSize = pageDomain.getPageSize();
|
|
|
|
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
|
|
|
|
{
|
|
|
|
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
2022-01-07 13:09:58 +08:00
|
|
|
Boolean reasonable = pageDomain.getReasonable();
|
|
|
|
PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
|
2021-12-18 12:22:41 +08:00
|
|
|
}
|
|
|
|
}
|
2022-03-31 11:48:27 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 清理分页的线程变量
|
|
|
|
*/
|
|
|
|
public static void clearPage()
|
|
|
|
{
|
|
|
|
PageHelper.clearPage();
|
|
|
|
}
|
2021-12-18 12:22:41 +08:00
|
|
|
}
|