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.business.constant.SystemConstant;
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 SaveExamParams extends BaseParams implements Serializable {

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

    @ApiModelProperty(value = "考试批次编码")
    String code;

    @ApiModelProperty(value = "考试名称")
    private String name;

    @ApiModelProperty(value = "考试时间(开始时间)")
    private String examTime;

    @ApiModelProperty(value = "考试类型(SCAN_IMAGE或MULTI_MEDIA)")
    private String type = SystemConstant.MULTI_MEDIA;

    public SaveExamParams() {

    }

    public SaveExamParams(Long orgId, Long id, String name, String examTime) {
        super(orgId, null, null);
        this.id = id;
        this.name = name;
        this.examTime = examTime;
    }

    public SaveExamParams(Long orgId, Long id, String code, String name, String examTime) {
        super(orgId, null, null);
        this.id = id;
        this.name = name;
        this.code = code;
        this.examTime = examTime;
    }


    public SaveExamParams(Long orgId, Long id, String code) {
        super(orgId, null, null);
        this.id = id;
        this.code = code;
    }

    /**
     * 校验参数
     */
    public void vaildParams() {
        if (Objects.isNull(this.id) && Objects.isNull(this.code)) {
            throw new BusinessException("id或code必填一个");
        }
        if (Objects.isNull(this.name)) {
            throw new BusinessException("考试名称不能为空");
        }
        if (Objects.isNull(this.examTime)) {
            throw new BusinessException("考试时间不能为空");
        }
    }

    public String getName() {
        return name;
    }

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

    public String getExamTime() {
        return examTime;
    }

    public void setExamTime(String examTime) {
        this.examTime = examTime;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

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