package com.ssj.service.kmt.dto;

import com.alibaba.fastjson.annotation.JSONField;
import com.ssj.service.kmt.constant.KnowledgeVersion;

import org.apache.commons.lang3.StringUtils;

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

public class ExerciseBookCourseDTO implements Serializable {

    private static final long serialVersionUID = -3341421097866292443L;

    private String id;
    private String name;
    @JSONField(serialize=false)
    private Integer version;
    @JSONField(serialize=false)
    private String courseName;
    @JSONField(serialize=false)
    private String grade;
    @JSONField(serialize=false)
    private Integer semester;
    @JSONField(serialize=false)
    private String unit;
    @JSONField(serialize=false)
    private String period;

    public String getId() {
        return id;
    }

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

    public String getName() {
        if (StringUtils.isBlank(name)) {
            StringBuilder nameSb = new StringBuilder();

            nameSb.append(courseName);

            KnowledgeVersion knowledgeVersion = new KnowledgeVersion();
            knowledgeVersion.init();
            nameSb.append(knowledgeVersion.getVersionNameBySubjectAndVersionNum(courseName, version));

            nameSb.append(grade);

            if (Objects.equals(1, semester)) {
                nameSb.append("上册");
            } else {
                nameSb.append("下册");
            }

            nameSb.append(unit);
            nameSb.append(period);

            name = nameSb.toString();
        }

        return name;
    }

    public String getCourseName() {
        return courseName;
    }

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

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public String getGrade() {
        return grade;
    }

    public void setGrade(String grade) {
        this.grade = grade;
    }

    public Integer getSemester() {
        return semester;
    }

    public void setSemester(Integer semester) {
        this.semester = semester;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public String getPeriod() {
        return period;
    }

    public void setPeriod(String period) {
        this.period = period;
    }
}
