namespace Admin.NET.Plugin.AiDOP.DataPlatform; public sealed class MdpTenantStdSource { public string SourceSystem { get; init; } = ""; public string SourceScope { get; init; } = ""; } /// 未登记或来源不一致时返回 null。不回退任何默认来源。 public sealed class MdpTenantStdSourceResolver : ITransient { private readonly ISqlSugarClient _db; public MdpTenantStdSourceResolver(ISqlSugarClient db) => _db = db; public async Task GetSourceAsync(long tenantId, string stdObject, CancellationToken cancellationToken = default) { if (tenantId <= 0 || string.IsNullOrWhiteSpace(stdObject)) return null; var rows = await _db.Ado.SqlQueryAsync( """ SELECT source_system AS SourceSystem, IFNULL(source_scope,'') AS SourceScope FROM mdp_tenant_std_source WHERE tenant_id=@tenant AND std_object=@obj LIMIT 1 """, new { tenant = tenantId, obj = stdObject.Trim() }); cancellationToken.ThrowIfCancellationRequested(); return rows.FirstOrDefault(); } }