package com.haha.common.enums;

public enum AssetStatus {

    NORMAL("NORMAL", "正常运行"),
    REPAIR("REPAIR", "故障维修"),
    IDLE("IDLE", "闲置撤机");

    private final String code;
    private final String description;

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

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static AssetStatus fromCode(String code) {
        if (code == null) {
            return null;
        }
        for (AssetStatus assetStatus : values()) {
            if (assetStatus.code.equals(code)) {
                return assetStatus;
            }
        }
        return null;
    }

    public static String getDescription(String code) {
        AssetStatus assetStatus = fromCode(code);
        return assetStatus != null ? assetStatus.description : "未知";
    }
}
