package com.xzzn.common.enums;

/**
 * MQTT主题处理类型未知类型
 */
public enum TopicHandleType {
    DEVICE("DEVICE", "设备数据"),
    DEVICE_ALARM("DEVICE_ALARM", "设备告警数据"),
    STRATEGY("STRATEGY", "策略数据"),
    SYSTEM("SYSTEM", "系统数据"),
    ;

    private final String code;
    private final String info;

    TopicHandleType(String code, String info) {
        this.code = code;
        this.info = info;
    }

    public String getName() {
        return code;
    }

    public String getInfo() {
        return info;
    }

    // 根据名称查找枚举
    public static TopicHandleType getEnumByCode(String code) {
        for (TopicHandleType type : values()) {
            if (type.getName().equals(code)) {
                return type;
            }
        }
        // 默认返回SYSTEM
        return SYSTEM;
    }
}
