| 12345678910111213141516171819202122232425262728293031 |
- namespace Admin.NET.Plugin.AiDOP.DataPlatform;
- public sealed class MdpTenantStdSource
- {
- public string SourceSystem { get; init; } = "";
- public string SourceScope { get; init; } = "";
- }
- /// <summary>未登记或来源不一致时返回 null。不回退任何默认来源。</summary>
- public sealed class MdpTenantStdSourceResolver : ITransient
- {
- private readonly ISqlSugarClient _db;
- public MdpTenantStdSourceResolver(ISqlSugarClient db) => _db = db;
- public async Task<MdpTenantStdSource?> GetSourceAsync(long tenantId, string stdObject, CancellationToken cancellationToken = default)
- {
- if (tenantId <= 0 || string.IsNullOrWhiteSpace(stdObject))
- return null;
- var rows = await _db.Ado.SqlQueryAsync<MdpTenantStdSource>(
- """
- 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();
- }
- }
|