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_CODE("studentCode", "学号"),
    TICKET_NUMBER("ticketNumber", "考号"),
    SITE_NUMBER("siteNumber", "座位号"),
    STUDENT_NAME("studentName","姓名"),
    COURSE_CODE("courseCode","课程代码"),
    COURSE_NAME("courseName","课程名称"),
    PAPER_NUMBER("paperNumber","试卷编号"),
    CAMPUS_NAME("campusName","校区"),
    EXAM_PLACE("examPlace","考点"),
    EXAM_ROOM("examRoom","考场"),
    EXAM_DATE("examDate","考试日期"),
    EXAM_TIME("examTime","考试时间");


    private String code;
    private String desc;

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    RequiredFieldsEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }


    /**
     * @return
     */
    public static List<EnumResult> listTypes() {
        List<EnumResult> list = new ArrayList<>();
        for (RequiredFieldsEnum value : RequiredFieldsEnum.values()) {
            EnumResult result = new EnumResult();
            result.setName(value.name());
            result.setOrdinal(value.ordinal());
            result.setCode(value.getCode());
            result.setDesc(value.getDesc());
            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;
    }
}
