package com.ym.mec.education.enums;

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

/**
 * 学生考勤状态
 */
public enum StudentAttendanceStatusEnum implements BaseEnum<String,StudentAttendanceStatusEnum> {
    NORMAL("NORMAL","正常"),
    TRUANT("TRUANT","旷课"),
    LEAVE("LEAVE","请假"),
    QUIT_SCHOOL("QUIT_SCHOOL","休学"),
    DROP_OUT("DROP_OUT","退学");

    private String code;

    private String msg;

    StudentAttendanceStatusEnum(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(StudentAttendanceStatusEnum.values())
                .filter(StudentAttendanceStatusEnum -> StudentAttendanceStatusEnum.getCode().equals(code))
                .findFirst()
                .map(StudentAttendanceStatusEnum::getMsg).orElse(null);
    }
}
