package com.securitycontrol.common.core.utils;

import com.github.pagehelper.PageHelper;
import com.securitycontrol.common.core.web.page.PageDomain;
import com.securitycontrol.common.core.web.page.TableSupport;

/**
 * 分页工具类
 *
 * @author czc
 */
public class PageUtils extends PageHelper
{
    /**
     * 设置请求分页数据
     */
    public static void startPage()
    {
        PageDomain pageDomain = TableSupport.buildPageRequest();

        Integer pageNum = pageDomain.getPageNum();
        Integer pageSize = pageDomain.getPageSize();
        Boolean reasonable = pageDomain.getReasonable();
        PageHelper.startPage(pageNum, pageSize, null).setReasonable(reasonable);
    }
    public static void startLayPage()
    {
        PageDomain pageDomain = TableSupport.buildLayPageRequest();
        Integer pageNum = pageDomain.getPage();
        Integer pageSize = pageDomain.getLimit();
        Boolean reasonable = pageDomain.getReasonable();
        PageHelper.startPage(pageNum, pageSize, null).setReasonable(reasonable);
    }

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