package com.ruoyi.web.modules.trading.support;

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;

/**
 * 供应商小程序分页。
 */
public final class AppSupplierPageSupport
{
    private static final int DEFAULT_PAGE_NUM = 1;

    private static final int DEFAULT_PAGE_SIZE = 10;

    private AppSupplierPageSupport()
    {
    }

    public static void startPage()
    {
        PageDomain page = TableSupport.buildPageRequest();
        Integer pageNum = page.getPageNum() != null ? page.getPageNum() : DEFAULT_PAGE_NUM;
        Integer pageSize = page.getPageSize() != null ? page.getPageSize() : DEFAULT_PAGE_SIZE;
        String orderBy = SqlUtil.escapeOrderBySql(page.getOrderBy());
        Boolean reasonable = page.getReasonable();
        PageHelper.startPage(pageNum, pageSize, orderBy)
                .setReasonable(reasonable != null ? reasonable : Boolean.TRUE);
    }
}
