| 123456789101112131415161718192021222324 |
- namespace Admin.NET.Plugin.AiDOP.Infrastructure;
- /// <summary>
- /// 运营事实与 KPI 日值的工厂兼容:租户隔离仍只信 tenant_id;
- /// 历史 DWD/KPI 使用 factory_id=1,可信作用域使用租户 OrgId。
- /// 禁止把 factory_id=tenant_id 当成工厂。
- /// </summary>
- public static class SmartOpsOperationalFactory
- {
- public const long LegacyDefaultFactoryId = 1;
- public static bool Matches(long tenantId, long trustedFactoryId, long? rowFactoryId)
- {
- if (rowFactoryId is null or 0) return true;
- if (rowFactoryId.Value == tenantId) return false;
- return rowFactoryId.Value == LegacyDefaultFactoryId || rowFactoryId.Value == trustedFactoryId;
- }
- public static string SqlPredicate(
- string column = "factory_id",
- string factoryParam = "@factoryId",
- string tenantParam = "@tenantId") =>
- $"({column} IS NULL OR {column}=0 OR {column}={LegacyDefaultFactoryId} OR {column}={factoryParam}) AND ({column} IS NULL OR {column}<>{tenantParam})";
- }
|