package com.jxy.common.core.utils;

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

/**
 * @Description 分页工具类
 * @Date 2022/5/10 14:37
 * @Author 杜懿
 */
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();
    }
}

