package com.qmth.teachcloud.report.business.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qmth.teachcloud.common.contant.SystemConstant;
import com.qmth.teachcloud.common.enums.AssignEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

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

/**
 * <p>
 * 试卷基础信息表（赋分系数、试卷类型、满分、及格分等）
 * </p>
 *
 * @author wangliang
 * @since 2021-06-01
 */
@ApiModel(value = "TBPaper对象", description = "试卷基础信息表（赋分系数、试卷类型、满分、及格分等）")
public class TBPaper implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "试卷id")
    @JsonSerialize(using = ToStringSerializer.class)
    @TableId(value = "id")
    private Long id;

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

    @ApiModelProperty(value = "科目编码")
    @TableField(value = "course_code")
    private String courseCode;

    @ApiModelProperty(value = "科目名称")
    @TableField(value = "course_name")
    private String courseName;

    @ApiModelProperty(value = "试卷类型")
    @TableField(value = "paper_type")
    private String paperType;

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

    @ApiModelProperty(value = "该试卷考试结束时间")
    @TableField(value = "end_time")
    private Long endTime;

    @ApiModelProperty(value = "赋分系数（赋值分=卷面成绩 +（卷面满分-卷面成绩）/ 赋分系数）")
    @TableField(value = "coefficient")
    private BigDecimal coefficient;

    @ApiModelProperty(value = "试卷满分")
    @TableField(value = "total_score")
    private BigDecimal totalScore;

    @ApiModelProperty(value = "试卷及格分")
    @TableField(value = "pass_score")
    private BigDecimal passScore;

    @ApiModelProperty(value = "赋分类型\n1.NEED_ASSIGN_SCORE('是','需要且按照公式赋分')\n2.NO_NEED_ASSIGN_SCORE('否','不需要赋分，标准分即为赋分')\n3.SPECIAL_ASSIGN_SCORE('特殊赋分','特殊赋分，按照excel表进行赋分')")
    @TableField(value = "score_type")
    private AssignEnum scoreType;

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public Long getId() {
        return id;
    }

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

    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 String getCourseName() {
        return courseName;
    }

    public void setCourseName(String courseName) {
        this.courseName = courseName;
    }

    public String getPaperType() {
        return paperType;
    }

    public void setPaperType(String paperType) {
        this.paperType = paperType;
    }

    public Long getStartTime() {
        return startTime;
    }

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

    public Long getEndTime() {
        return endTime;
    }

    public void setEndTime(Long endTime) {
        this.endTime = endTime;
    }

    public BigDecimal getCoefficient() {
        if (Objects.nonNull(coefficient)) {
            return coefficient.setScale(SystemConstant.CALCULATE_SCALE, BigDecimal.ROUND_HALF_UP);
        } else {
            return coefficient;
        }
    }

    public void setCoefficient(BigDecimal coefficient) {
        this.coefficient = coefficient;
    }

    public BigDecimal getTotalScore() {
        if (Objects.nonNull(totalScore)) {
            return totalScore.setScale(SystemConstant.CALCULATE_SCALE, BigDecimal.ROUND_HALF_UP);
        } else {
            return totalScore;
        }
    }

    public void setTotalScore(BigDecimal totalScore) {
        this.totalScore = totalScore;
    }

    public BigDecimal getPassScore() {
        if (Objects.nonNull(passScore)) {
            return passScore.setScale(SystemConstant.CALCULATE_SCALE, BigDecimal.ROUND_HALF_UP);
        } else {
            return passScore;
        }
    }

    public void setPassScore(BigDecimal passScore) {
        this.passScore = passScore;
    }

    public AssignEnum getScoreType() {
        return scoreType;
    }

    public void setScoreType(AssignEnum scoreType) {
        this.scoreType = scoreType;
    }
}
