package cc.iotkit.data.config;

import com.alibaba.ttl.TransmittableThreadLocal;

public class TenantContext {

   // private static final ThreadLocal<Boolean> TENANT_FILTER_DISABLED = ThreadLocal.withInitial(() -> false);
   private static final ThreadLocal<Boolean> TENANT_FILTER_DISABLED =
           new TransmittableThreadLocal<>(){
               @Override
               protected Boolean initialValue() {
                   return false; // 默认启用租户过滤
               }
           }; // 替换原实现
    public static void disableTenantFilter() {
        TENANT_FILTER_DISABLED.set(true);
    }

    public static void enableTenantFilter() {
        TENANT_FILTER_DISABLED.set(false);
    }

    public static boolean isFilterDisabled() {
        return TENANT_FILTER_DISABLED.get();
    }
}
