package com.dcs.hnyz.enums;

import static com.dcs.framework.datasource.DynamicDataSourceContextHolder.log;

/**
 * TriggerTypeEnum
 * 动作配置触发类型
 * @author: hmy
 * @date: 2025/5/28 14:30
 */
public enum TriggerTypeEnum {
    TIMED_TRIGGER("1", "定时触发"),
    CONDITION_TRIGGER("2", "条件触发"),
    SYNC_TRIGGER("3", "同步触发");

    private final String code;
    private final String label;

    TriggerTypeEnum(String code, String label) {
        this.code = code;
        this.label = label;
    }

    public String getCode() {
        return code;
    }

    public String getLabel() {
        return label;
    }

    public static TriggerTypeEnum fromCode(String code) {
        for (TriggerTypeEnum type : values()) {
            if (code.equals(type.code)) return type;
        }
        log.warn("未知设备类型: {}", code);
        return null;
    }
}
