package com.lesingle.edu.common.enums;

import lombok.Getter;

/**
 * 学生班级状态枚举
 * 用于标识学生在班级中的在班/离班状态
 */
@Getter
public enum StudentClassStatus {

    ACTIVE("ACTIVE", "在班"),
    INACTIVE("INACTIVE", "离班");

    private final String code;
    private final String description;

    StudentClassStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 根据 code 值获取枚举
     */
    public static StudentClassStatus fromCode(String code) {
        if (code == null) {
            return INACTIVE;
        }
        for (StudentClassStatus status : values()) {
            if (status.getCode().equalsIgnoreCase(code)) {
                return status;
            }
        }
        return INACTIVE;
    }

    /**
     * 判断是否为在班状态
     */
    public static boolean isActive(String status) {
        return ACTIVE.getCode().equalsIgnoreCase(status);
    }

    /**
     * 判断当前是否为在班状态
     */
    public boolean isActive() {
        return this == ACTIVE;
    }

}
