package com.qmth.teachcloud.report.business.bean.params;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.Optional;

/**
 * @Description: 课程参数
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2022/5/27
 */
public class CourseParam implements Serializable {

    @ApiModelProperty(value = "考试id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long examId;

    @ApiModelProperty(value = "课程编码，一个分析试卷的唯一标识")
    private String courseCode;

    @ApiModelProperty(value = "课程名称，分析试卷名称（可用课程名称-试卷唯一性标识）")
    private String courseName;

    @ApiModelProperty(value = "试卷类型没有就传'#'")
    private String paperType = "#";

    @ApiModelProperty(value = "开课机构名称（命题机构）")
    private String teachCollegeName;

    @ApiModelProperty(value = "启用/禁用，ture：启用，false：禁用，默认启用")
    Boolean enable = true;

    /**
     * 参数校验
     */
    public void validParamsExamIdAndCourseCode() {
        Optional.ofNullable(this.getExamId()).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("考试id为空"));
        Optional.ofNullable(this.getCourseCode()).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("课程编码为空"));
    }

    /**
     * 参数校验
     */
    public void validParams() {
        Optional.ofNullable(this.getExamId()).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("考试id为空"));
        Optional.ofNullable(this.getCourseCode()).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("课程编码为空"));
        Optional.ofNullable(this.getCourseName()).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("课程名称为空"));
        Optional.ofNullable(this.getTeachCollegeName()).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("开课机构名称为空"));
    }

    public Boolean getEnable() {
        return enable;
    }

    public void setEnable(Boolean enable) {
        this.enable = enable;
    }

    public Long getExamId() {
        return examId;
    }

    public void setExamId(Long examId) {
        this.examId = examId;
    }

    public String getCourseCode() {
        return courseCode;
    }

    public void setCourseCode(String courseCode) {
        this.courseCode = courseCode;
    }

    public String getCourseName() {
        return courseName;
    }

    public void setCourseName(String courseName) {
        this.courseName = courseName;
    }

    public String getPaperType() {
        return paperType;
    }

    public void setPaperType(String paperType) {
        this.paperType = paperType;
    }

    public String getTeachCollegeName() {
        return teachCollegeName;
    }

    public void setTeachCollegeName(String teachCollegeName) {
        this.teachCollegeName = teachCollegeName;
    }
}
