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

import com.github.pagehelper.PageHelper;
import com.ruoyi.web.modules.booking.domain.AppBookingResourceQuery;

/**
 * 预约资源/评价列表分页。
 */
public final class AppBookingPageSupport
{
    private AppBookingPageSupport()
    {
    }

    public static void startPage(AppBookingResourceQuery query)
    {
        AppBookingResourceQuery effective = AppBookingResourceQuerySupport.normalize(query);
        PageHelper.startPage(effective.getPageNum(), effective.getPageSize()).setReasonable(true);
    }

    public static void startPage(Integer pageNum, Integer pageSize)
    {
        int pn = pageNum != null && pageNum >= 1 ? pageNum : AppointmentResourceRules.DEFAULT_PAGE_NUM;
        int ps = pageSize != null && pageSize >= 1 ? pageSize : AppointmentResourceRules.DEFAULT_PAGE_SIZE;
        ps = Math.min(ps, AppointmentResourceRules.MAX_PAGE_SIZE);
        PageHelper.startPage(pn, ps).setReasonable(true);
    }
}
