package com.lesingle.edu.common.enums;

import lombok.Getter;

/**
 * 通用状态枚举
 * 用于统一各实体中 active/ACTIVE 等状态值
 */
@Getter
public enum GenericStatus {

    ACTIVE("ACTIVE", "启用"),
    INACTIVE("INACTIVE", "停用"),
    ARCHIVED("ARCHIVED", "归档");

    private final String code;
    private final String description;

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

    public static GenericStatus fromCode(String code) {
        if (code == null) {
            return INACTIVE;
        }
        for (GenericStatus 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;
    }

}
