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

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

/**
 * @author reghao
 * @date 2024-09-14 15:49:02
 */
public enum ExamRole {
    TEACHER(1, "教师"),
    STUDENT(2, "学生");

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

    ExamRole(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 ExamRole getByCode(int code) {
        return map.get(code);
    }
}
