package com.usky.issue.service.enums;

import lombok.Getter;

/**
 * 同步数据类型
 *
 * @author fyc
 * @date 2026-05-21
 */
@Getter
public enum SyncTypeEnum {

    TENANT("TENANT", "租户", false),
    USER("USER", "用户", false),
    ALARM("ALARM", "告警", false),
    BUILDING("BUILDING", "建筑工程数据", true),
    IOT_FACILITY("IOT_FACILITY", "物联设施数据", true),
    IOT_MONITOR("IOT_MONITOR", "物联监测数据", true);

    private final String code;
    private final String label;
    /** 是否异步大批量同步 */
    private final boolean async;

    SyncTypeEnum(String code, String label, boolean async) {
        this.code = code;
        this.label = label;
        this.async = async;
    }

    public static SyncTypeEnum fromCode(String code) {
        if (code == null) {
            throw new IllegalArgumentException("未知同步类型: null");
        }
        String normalized = code.trim();
        for (SyncTypeEnum type : values()) {
            if (type.code.equalsIgnoreCase(normalized)) {
                return type;
            }
        }
        throw new IllegalArgumentException("未知同步类型: " + code);
    }
}
