package com.qmth.themis.business.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qmth.themis.business.base.BaseEntity;
import com.qmth.themis.business.constant.SystemConstant;
import com.qmth.themis.business.util.UidUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.Objects;

/**
 * @Description: 考试场次
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/6/25
 */
@ApiModel(value = "t_e_exam_activity", description = "考试场次")
public class TEExamActivity extends BaseEntity {

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "批次id")
    @TableField(value = "exam_id")
    private Long examId;

    @ApiModelProperty(value = "场次代码")
    @TableField(value = "code")
    private String code;

    @ApiModelProperty(value = "提前多长时间开始候考(分钟)")
    @TableField(value = "prepare_seconds")
    private Integer prepareSeconds;

    @ApiModelProperty(value = "最大考试时长")
    @TableField(value = "max_duration_seconds")
    private Integer maxDurationSeconds;

    @ApiModelProperty(value = "是否启用，0：停用，1：启用")
    @TableField(value = "enable")
    private Integer enable;

    @ApiModelProperty(value = "允许开考时长(分钟)")
    @TableField(value = "opening_seconds")
    private Integer openingSeconds;

    @ApiModelProperty(value = "开考时间")
    @TableField(value = "start_time")
    private Long startTime;

    @ApiModelProperty(value = "结束时间")
    @TableField(value = "finish_time")
    private Long finishTime;

    public TEExamActivity() {

    }

    public TEExamActivity(Long examId, Integer prepareSeconds, Integer maxDurationSeconds, Integer openingSeconds,
                          Long startTime, Long finishTime, Long createId) {
        setId(UidUtil.nextId());
        this.examId = examId;
        this.code = "examActivity" + getId();
        this.prepareSeconds = prepareSeconds;
        this.maxDurationSeconds = maxDurationSeconds;
        this.openingSeconds = openingSeconds;
        this.startTime = startTime;
        this.finishTime = finishTime;
        setCreateId(createId);
    }

    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 Integer getPrepareSeconds() {
        return prepareSeconds;
    }

    public void setPrepareSeconds(Integer prepareSeconds) {
        this.prepareSeconds = prepareSeconds;
    }

    public Integer getMaxDurationSeconds() {
        return maxDurationSeconds;
    }

    public void setMaxDurationSeconds(Integer maxDurationSeconds) {
        this.maxDurationSeconds = maxDurationSeconds;
    }

    public Integer getEnable() {
        return enable;
    }

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

    public Integer getOpeningSeconds() {
        return openingSeconds;
    }

    public void setOpeningSeconds(Integer openingSeconds) {
        this.openingSeconds = openingSeconds;
    }

    public Long getStartTime() {
        return startTime;
    }

    public void setStartTime(Long startTime) {
        this.startTime = startTime;
    }

    public Long getFinishTime() {
        return finishTime;
    }

    public void setFinishTime(Long finishTime) {
        this.finishTime = finishTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        TEExamActivity that = (TEExamActivity) o;
        return Objects.equals(examId, that.examId) && Objects.equals(code, that.code) && Objects.equals(prepareSeconds, that.prepareSeconds) && Objects.equals(maxDurationSeconds, that.maxDurationSeconds) && Objects.equals(enable, that.enable) && Objects.equals(openingSeconds, that.openingSeconds) && Objects.equals(startTime, that.startTime) && Objects.equals(finishTime, that.finishTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(examId, code, prepareSeconds, maxDurationSeconds, enable, openingSeconds, startTime, finishTime);
    }

    @Override
    public String toString() {
        return "TEExamActivity{" +
                "examId=" + examId +
                ", code='" + code + '\'' +
                ", prepareSeconds=" + prepareSeconds +
                ", maxDurationSeconds=" + maxDurationSeconds +
                ", enable=" + enable +
                ", openingSeconds=" + openingSeconds +
                ", startTime=" + startTime +
                ", finishTime=" + finishTime +
                '}';
    }
}
