package com.seer.teach.common.enums.teacher;

/**
 * 课程状态枚举类
 * 定义了教学过程中各种状态的枚举值
 */
public enum LessonStateEnum {

    LECTURE(0,"讲课中"),

    LECTURE_STOP(1,"讲课结束"),

    MODEL_ASK(2,"模型主动提问"),

    INTERACT(3,"互动"),

    SUMMARY(4,"小结");

    private final Integer key;

    private final String desc;

    /**
     * 构造函数
     * @param key 状态键值
     * @param desc 状态描述
     */
    LessonStateEnum(Integer key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    /**
     * 获取状态键值
     * @return 状态键值
     */
    public Integer getKey() {
        return key;
    }

    /**
     * 获取状态描述
     * @return 状态描述
     */
    public String getDesc() {
        return desc;
    }

    /**
     * 根据键值获取对应的枚举对象
     * @param key 要查找的键值
     * @return 对应的枚举对象
     * @throws RuntimeException 当找不到对应枚举时抛出异常
     */
    public static LessonStateEnum getByKey(Integer key) {
        // 遍历所有枚举值查找匹配项
        for (LessonStateEnum e : values()) {
            if (e.getKey().equals(key)) {
                return e;
            }
        }
        throw new RuntimeException("enum not exists.");
    }

}
