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

import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.web.modules.booking.domain.AppMyAppointmentQuery;

/**
 * 我的预约查询参数规范化。
 */
public final class AppMyAppointmentQuerySupport
{
    private AppMyAppointmentQuerySupport()
    {
    }

    public static AppMyAppointmentQuery normalize(AppMyAppointmentQuery query, String createBy)
    {
        AppMyAppointmentQuery effective = query != null ? query : new AppMyAppointmentQuery();
        if (!MyAppointmentStatusTabRules.isValidProviderType(effective.getProviderType()))
        {
            throw new ServiceException("预约类型不能为空");
        }
        effective.setStatusTab(MyAppointmentStatusTabRules.normalizeTab(effective.getStatusTab()));
        effective.setCreateBy(createBy);
        effective.setPageNum(AppBookingResourceQuerySupport.resolvePageNum(effective.getPageNum()));
        effective.setPageSize(AppBookingResourceQuerySupport.resolvePageSize(effective.getPageSize()));
        return effective;
    }
}
