package com.m2pool.common.core.utils;

import com.github.pagehelper.PageHelper;
import com.m2pool.common.core.utils.sql.SqlUtil;
import com.m2pool.common.core.web.page.Page;
import com.m2pool.common.core.web.page.TableSupport;

/**
 * @Description 分页工具类
 * @Date 2024/6/12 14:37
 * @Author dy
 */
public class PageUtils extends PageHelper
{
    /**
     * 设置请求分页数据
     */
    public static void startPage()
    {
        Page page = TableSupport.buildPageRequest();
        Integer pageNum = page.getPageNum();
        Integer pageSize = page.getPageSize();
        String orderBy = SqlUtil.escapeOrderBySql(page.getOrderBy());
        Boolean reasonable = page.getReasonable();
        PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
    }

    /**
     * 清理分页的线程变量
     */
    public static void clearPage()
    {
        PageHelper.clearPage();
    }
}

