package com.ssj.service.kmt.exercisesys.dto;

import com.alibaba.fastjson.annotation.JSONField;
import org.apache.commons.lang3.StringUtils;

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

/**
 * @author yrf
 * @description
 * @time 2020/3/25 16:56
 */
public class TeacherInfoStatusDetailDTO implements Serializable {

    private static final long serialVersionUID = 7774075479952665380L;

    /**
     * teacherId :
     * image :
     * name :
     * school :
     * sex : 1
     * createTime : 人教版
     * major :
     * telephone : 12312
     * teacherTypeStr :
     * teacherWorkingType : 1
     */

    private String teacherId;
    private String image;
    private String name;
    private String school;
    private Integer sex;
    /**
     * 科目
     */
    private String subject;

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    @JSONField(format = "yyyy.MM.dd")
    private Date createTime;

    private String major;
    private String telephone;

    @JSONField(serialize = false)
    private String authority;

    private String teacherTypeStr;

    @JSONField(serialize = false)
    private Integer isBanned;

    @JSONField(serialize = false)
    private Integer isCancelled;

    @JSONField(serialize = false)
    private Integer isFormal;

    /**
     * 角色状态 1考核中，2在职， 3已冻结，4已注销
     */
    private Integer teacherWorkingType;

    public String getTeacherId() {
        return teacherId;
    }

    public void setTeacherId(String teacherId) {
        this.teacherId = teacherId;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public String getName() {
        return name;
    }

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

    public String getSchool() {
        return school;
    }

    public void setSchool(String school) {
        this.school = school;
    }

    public Integer getSex() {
        return sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getMajor() {
        return major;
    }

    public void setMajor(String major) {
        this.major = major;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getTeacherTypeStr() {
        if (StringUtils.isNotBlank(teacherTypeStr)) {
            return teacherTypeStr;
        }

        StringBuilder exerciseTeacherTypeBuilder = new StringBuilder("");
        if (authority.contains("1")) {
            exerciseTeacherTypeBuilder.append("加工、");
        }
        if (authority.contains("2")) {
            exerciseTeacherTypeBuilder.append("加审、");
        }
        if (authority.contains("3")) {
            exerciseTeacherTypeBuilder.append("解析、");
        }
        if (authority.contains("4")) {
            exerciseTeacherTypeBuilder.append("解审、");
        }
        if (exerciseTeacherTypeBuilder.length() > 0) {
            exerciseTeacherTypeBuilder.deleteCharAt(exerciseTeacherTypeBuilder.length() - 1);
        }
        StringBuilder kmtTeacherTypeBuilder = new StringBuilder("");
        if (authority.contains("5")) {
            kmtTeacherTypeBuilder.append("加工、");
        }
        if (authority.contains("6")) {
            kmtTeacherTypeBuilder.append("审核、");
        }
        if (kmtTeacherTypeBuilder.length() > 0) {
            kmtTeacherTypeBuilder.deleteCharAt(kmtTeacherTypeBuilder.length() - 1);
        }
        teacherTypeStr = (exerciseTeacherTypeBuilder.length() > 0 ? String.format("练习册（%s）   ", exerciseTeacherTypeBuilder.toString()) : "") +
                (kmtTeacherTypeBuilder.length() > 0 ? String.format("KMT （%s）", kmtTeacherTypeBuilder.toString()) : "");
        if (authority.contains("7")) {
            teacherTypeStr = "题库录入老师";
        }
        if (authority.contains("8")) {
            teacherTypeStr = "答案校对老师";
        }
        return teacherTypeStr;
    }

    public void setTeacherTypeStr(String teacherTypeStr) {
        this.teacherTypeStr = teacherTypeStr;
    }

    public Integer getTeacherWorkingType() {
        if (teacherWorkingType != null) {
            return teacherWorkingType;
        }

        if (Objects.equals(isCancelled, 1)) {
            teacherWorkingType = 4;
        } else if (Objects.equals(isBanned, 1)) {
            teacherWorkingType = 3;
        } else if (Objects.equals(isFormal, 1)) {
            teacherWorkingType = 2;
        } else {
            teacherWorkingType = 1;
        }

        return teacherWorkingType;
    }

    public void setTeacherWorkingType(Integer teacherWorkingType) {
        this.teacherWorkingType = teacherWorkingType;
    }
}
