package com.qmth.distributed.print.business.enums;

import com.qmth.teachcloud.common.enums.EnumResult;

import java.util.ArrayList;
import java.util.List;

/**
 * 考务必选字段(此枚举类中的字段必须在ExaminationImportDto类中有对应的属性code作为属性名，同时该属性必须加@ExcelDBFieldDesc注解，且name必须和desc对应)
 * @Date: 2021/3/29.
 */
public enum RequiredFieldsEnum {

    STUDENT_NAME("studentName","姓名", true, true),
    STUDENT_CODE("studentCode", "学号", true, true),
    //    TICKET_NUMBER("ticketNumber", "考号", false, false),
    SITE_NUMBER("siteNumber", "座位号", false, false),
    COURSE_NAME("courseName","课程名称", true, true),
    COURSE_CODE("courseCode","课程代码", true, true),
    PAPER_NUMBER("paperNumber","试卷编号", true, true),
    EXAM_DATE("examDate","考试日期", true, true),
    EXAM_TIME("examTime","考试时间", true, true),
    EXAM_PLACE("examPlace","校区（考点）", true, true),
    EXAM_ROOM("examRoom","考试教室（考场）", true, true),
    COLLEGE_NAME("collegeName","学院", true, true),
    MAJOR_NAME("majorName","专业", false, false),
    TEACH_CLAZZ_NAME("teachClazzName","教学班", true, true),
    CLAZZ_NAME("clazzName","行政班", false, false),
    TEACHER_NAME("teacherName","任课老师", false, false);

    private final String code;
    private final String name;

    private final Boolean enable;
    private final Boolean disabled;

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public Boolean getEnable() {
        return enable;
    }

    public Boolean getDisabled() {
        return disabled;
    }

    RequiredFieldsEnum(String code, String name, Boolean enable, Boolean disabled) {
        this.code = code;
        this.name = name;
        this.enable = enable;
        this.disabled = disabled;
    }


    /**
     * @return
     */
    public static List<EnumResult> listTypes() {
        List<EnumResult> list = new ArrayList<>();
        for (RequiredFieldsEnum value : RequiredFieldsEnum.values()) {
            EnumResult result = new EnumResult();
            result.setName(value.getName());
            result.setOrdinal(value.ordinal());
            result.setCode(value.getCode());
            result.setEnable(value.getEnable());
            result.setDisabled(value.getDisabled());
            list.add(result);
        }
        return list;
    }

    /**
     * 是否包含
     * @param name
     * @return
     */
    public static boolean contain(String name){
        RequiredFieldsEnum[] values = RequiredFieldsEnum.values();
        for (RequiredFieldsEnum value : values) {
            if(value.name().equals(name)){
                return true;
            }
        }
        return false;
    }
}
