package cn.reghao.tnb.content.app.exam.model.constant;

import java.util.HashMap;
import java.util.Map;

/**
 * 试题类型
 *
 * @author reghao
 * @date 2024-08-24 23:31:18
 */
public enum QuestionType {
    QUESTION1(1, "单选题"),
    QUESTION2(2, "多选题"),
    QUESTION3(3, "判断题"),
    QUESTION4(4, "填空题"),
    QUESTION5(5, "问答题"),
    QUESTION6(6, "组合题");

    private final int code;
    private final String desc;
    private static Map<Integer, String> descMap = new HashMap<>();
    static {
        for (QuestionType type : QuestionType.values()) {
            descMap.put(type.code, type.desc);
        }
    }

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

    public String getName() {
        return this.name();
    }

    /**
     * 提供给 @ValidEnum 调用
     *
     * @param
     * @return
     * @date 2023-10-11 14:44:42
     */
    public int getValue() {
        return this.code;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDescByCode(int code) {
        return descMap.get(code);
    }
}
