package com.qmth.themis.business.dto.response;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import org.jetbrains.annotations.NotNull;

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

/**
 * @Description: 考试候考dto
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/8/3
 */
public class TEExamWaitDto implements Serializable, Comparable<TEExamWaitDto> {

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

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(name = "考试场次id")
    private Long examActivityId;//考试场次id

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

    @ApiModelProperty(name = "考试编码")
    private String code;//考试编码

    @ApiModelProperty(name = "考试场次集合")
    private List<TEExamActivityWaitDto> activities;

    public TEExamWaitDto() {

    }

    public TEExamWaitDto(Long id, Long examActivityId, String name, String code) {
        this.id = id;
        this.examActivityId = examActivityId;
        this.name = name;
        this.code = code;
    }

    public String getCode() {
        return code;
    }

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

    public Long getExamActivityId() {
        return examActivityId;
    }

    public void setExamActivityId(Long examActivityId) {
        this.examActivityId = examActivityId;
    }

    public Long getId() {
        return id;
    }

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

    public String getName() {
        if (Objects.nonNull(code)) {
            return name + "(" + code + ")";
        } else {
            return name;
        }
    }

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

    public List<TEExamActivityWaitDto> getActivities() {
        return activities;
    }

    public void setActivities(List<TEExamActivityWaitDto> activities) {
        this.activities = activities;
    }

    @Override
    public int compareTo(@NotNull TEExamWaitDto o) {
        if (o.getId() < this.getId()) {
            return 1;
        } else if (o.getId() > this.getId()) {
            return -1;
        } else {
            return 0;
        }
    }
}
