package com.kym.common.enums;

/**
 * 设备故障类型枚举
 *
 * @author skyline
 */
public enum FaultType {
    OFFLINE("offline", "设备离线"),
    WATER_SHORTAGE("water_shortage", "缺水"),
    FOAM_SHORTAGE("foam_shortage", "缺泡沫");

    private final String code;
    private final String desc;

    FaultType(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static FaultType fromCode(String code) {
        for (FaultType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("未知的故障类型: " + code);
    }
}
