package com.qmth.distributed.print.business.bean.params.open;

import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;
import java.util.Optional;

/**
 * @Description:
 * @Author: CaoZixuan
 * @Date:
 */
public class GradeOpenPageParams extends GradeOpenParams{
    @ApiModelProperty(value = "分页页数")
    @NotNull(message = "请输入分页页数")
    @Range(min = 1L, message = "请输入分页页数")
    private Integer pageNumber;

    @ApiModelProperty(value = "分页容量")
    @NotNull(message = "请输入分页容量")
    @Range(min = 1L, message = "请输入分页容量")
    private Integer pageSize;

    public Integer getPageNumber() {
        return pageNumber;
    }

    public void setPageNumber(Integer pageNumber) {
        this.pageNumber = pageNumber;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    @Override
    public void validParams() {
        super.validParams();
        Optional.ofNullable(this.getPageNumber()).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("分页页数为空"));
        Optional.ofNullable(this.getPageSize()).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("分页容量为空"));
    }
}
