package top.tqx.demo_1.enums;

import lombok.Getter;

/**
 * 答题类型枚举
 */
@Getter
public enum AnswerType {
    FORMAL_EXAM("formal_exam", "正式考试"),
    MOCK_EXAM("mock_exam", "模拟考"),
    PRACTICE("practice", "日常练习");

    private final String code;
    private final String desc;

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

    /**
     * 根据code获取枚举
     */
    public static AnswerType fromCode(String code) {
        for (AnswerType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        return null;
    }
}
