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.util.Optional;

/**
 * @Description: 开放接口 - 发布报告参数
 * @Author: CaoZixuan
 * @Date: 2022-06-16
 */
public class PublishParams {
    @ApiModelProperty(value = "考试id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long examId;

    @ApiModelProperty(value = "课程编号")
    private String courseCode;

    @ApiModelProperty(value = "发布状态 true：发布 false:撤回发布")
    private Boolean publishStatus;

    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 Boolean getPublishStatus() {
        return publishStatus;
    }

    public void setPublishStatus(Boolean publishStatus) {
        this.publishStatus = publishStatus;
    }

    /**
     * 参数校验
     */
    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.getPublishStatus()).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("发布状态为空"));
    }
}
