package com.ym.mec.education.enums;

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

//老师签到状态(1正常签到，0异常签到，2正常签退)
public enum SignStatusEnum implements BaseEnum<Integer, SignStatusEnum> {
    SIGN(1,"正常签到"),
    EXCEPTION(0,"异常签到"),
    YES_QUIT(2,"正常签退");

    private Integer code;
    private String msg;

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

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

    public String getMsg() {
        return msg;
    }

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

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

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