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

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

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

/**
 * 考务必选字段
 * @Date: 2021/3/29.
 */
public enum CardRequiredFieldsEnum {

    TICKET_NUMBER("ticketNumber", "考号"),
    SITE_NUMBER("siteNumber", "座位号"),
    STUDENT_NAME("studentName","姓名"),
    COURSE_NAME("courseName","课程名称");

    private String code;
    private String desc;

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

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


    /**
     * @return
     */
    public static List<EnumResult> listTypes() {
        List<EnumResult> list = new ArrayList<>();
        for (CardRequiredFieldsEnum value : CardRequiredFieldsEnum.values()) {
            // 校验是否在考务必选字段中
            if(!RequiredFieldsEnum.contain(value.name())){
                throw ExceptionResultEnum.ERROR.exception("");
            }

            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;
    }
}
