package com.haha.common.enums;

public enum AssetType {

    VENDING_MACHINE("VENDING_MACHINE", "自助售卖机"),
    MICROWAVE("MICROWAVE", "微波炉");

    private final String code;
    private final String description;

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

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

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

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