package com.qmth.themis.business.bean.cloudmark;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qmth.themis.common.exception.BusinessException;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.Objects;

/**
 * @Description: 推送云阅卷科目接口参数
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2022/9/28
 */
public class SaveSubjectParams extends BaseParams implements Serializable {

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

    @ApiModelProperty(value = "科目编码")
    String code;

    @ApiModelProperty(value = "科目名称")
    String name;

    public SaveSubjectParams(Long orgId, Long examId, String code, String name) {
        super(orgId, null, null);
        this.examId = examId;
        this.code = code;
        this.name = name;
    }

    public SaveSubjectParams(Long orgId, Long examId, String code, String name, String accessKey, String accessSecret) {
        super(orgId, accessKey, accessSecret);
        this.examId = examId;
        this.code = code;
        this.name = name;
    }

    /**
     * 校验参数
     */
    public void vaildParams() {
        if (Objects.isNull(this.examId)) {
            throw new BusinessException("云阅卷考试id不能为空");
        }
        if (Objects.isNull(this.code)) {
            throw new BusinessException("科目编码不能为空");
        }
        if (Objects.isNull(this.name)) {
            throw new BusinessException("科目名称不能为空");
        }
    }

    public Long getExamId() {
        return examId;
    }

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

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
