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

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

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

/**
 * @Description: 分布式印刷开放接口参数
 * @Author: CaoZixuan
 * @Date: 2022-06-08
 */
public class GradeOpenParams implements Serializable {
    @ApiModelProperty(value = "教研分析考试id")
    @NotNull(message = "请输入教研分析考试id")
    @Range(min = 1L, message = "请输入教研分析考试id")
    @DBVerify(value = "教研分析考试id", required = true, min = 1)
    private String thirdExamId;

    @ApiModelProperty(value = "教研分析课程编号")
    @NotNull(message = "请输入教研分析课程编号")
    @Length(min = 1, message = "请输入教研分析课程编号")
    @DBVerify(value = "教研分析课程编号", required = true, min = 1, max = 50)
    private String gradeCourseCode;

    public String getThirdExamId() {
        return thirdExamId;
    }

    public void setThirdExamId(String thirdExamId) {
        this.thirdExamId = thirdExamId;
    }

    public String getGradeCourseCode() {
        return gradeCourseCode;
    }

    public void setGradeCourseCode(String gradeCourseCode) {
        this.gradeCourseCode = gradeCourseCode;
    }

    /**
     * 参数校验
     */
    public void validParams() {
        Optional.ofNullable(this.getThirdExamId()).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("第三方考试id为空"));
        Optional.ofNullable(this.getGradeCourseCode()).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("课程编号为空"));
    }
}
