package com.ym.mec.education.enums;

import com.ym.mec.common.enums.BaseEnum;
import java.util.Arrays;

public enum TeachModeEnum implements BaseEnum<String, TeachModeEnum> {
    ONLINE("ONLINE", "线上"), OFFLINE("OFFLINE", "线下");

    private String code;

    private String msg;

    TeachModeEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public String getCode() {
        return this.code;
    }

    /**
     * 根据枚举值获取枚举信息
     *
     * @param code 枚举值
     * @return 枚举信息
     */
    public static String getMsgByCode(String code) {
        return Arrays.stream(TeachModeEnum.values())
            .filter(TeachModeEnum -> TeachModeEnum.getCode().equals(code))
            .findFirst()
            .map(TeachModeEnum::getMsg).orElse(null);
    }
}
