diff --git a/Fengling.Platform.Infrastructure/PlatformDbContext.cs b/Fengling.Platform.Infrastructure/PlatformDbContext.cs index 9dbb419..1126512 100644 --- a/Fengling.Platform.Infrastructure/PlatformDbContext.cs +++ b/Fengling.Platform.Infrastructure/PlatformDbContext.cs @@ -1,11 +1,13 @@ -namespace Fengling.Platform.Infrastructure; - using Fengling.Platform.Domain.AggregatesModel.RoleAggregate; using Fengling.Platform.Domain.AggregatesModel.TenantAggregate; using Fengling.Platform.Domain.AggregatesModel.UserAggregate; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; + +namespace Fengling.Platform.Infrastructure; + + public partial class PlatformDbContext(DbContextOptions options) : IdentityDbContext(options) { diff --git a/Fengling.Platform.Infrastructure/TenantManager.cs b/Fengling.Platform.Infrastructure/TenantManager.cs index e5132d5..13ee0c6 100644 --- a/Fengling.Platform.Infrastructure/TenantManager.cs +++ b/Fengling.Platform.Infrastructure/TenantManager.cs @@ -17,65 +17,58 @@ public interface ITenantManager Task SetTenantCodeAsync(Tenant tenant, string code, CancellationToken cancellationToken = default); } -public class TenantManager : ITenantManager +public sealed class TenantManager(ITenantStore store) : ITenantManager { - private readonly ITenantStore _store; - - public TenantManager(ITenantStore store) + public async Task FindByIdAsync(long tenantId, CancellationToken cancellationToken = default) { - _store = store; + return await store.FindByIdAsync(tenantId, cancellationToken); } - public virtual async Task FindByIdAsync(long tenantId, CancellationToken cancellationToken = default) + public async Task FindByTenantCodeAsync(string tenantCode, CancellationToken cancellationToken = default) { - return await _store.FindByIdAsync(tenantId, cancellationToken); + return await store.FindByTenantCodeAsync(tenantCode, cancellationToken); } - public virtual async Task FindByTenantCodeAsync(string tenantCode, CancellationToken cancellationToken = default) + public async Task> GetAllAsync(CancellationToken cancellationToken = default) { - return await _store.FindByTenantCodeAsync(tenantCode, cancellationToken); + return await store.GetAllAsync(cancellationToken); } - public virtual async Task> GetAllAsync(CancellationToken cancellationToken = default) - { - return await _store.GetAllAsync(cancellationToken); - } - - public virtual async Task> GetPagedAsync(int page, int pageSize, string? name = null, + public async Task> GetPagedAsync(int page, int pageSize, string? name = null, string? tenantCode = null, TenantStatus? status = null, CancellationToken cancellationToken = default) { - return await _store.GetPagedAsync(page, pageSize, name, tenantCode, status, cancellationToken); + return await store.GetPagedAsync(page, pageSize, name, tenantCode, status, cancellationToken); } - public virtual async Task GetCountAsync(string? name = null, string? tenantCode = null, + public async Task GetCountAsync(string? name = null, string? tenantCode = null, TenantStatus? status = null, CancellationToken cancellationToken = default) { - return await _store.GetCountAsync(name, tenantCode, status, cancellationToken); + return await store.GetCountAsync(name, tenantCode, status, cancellationToken); } - public virtual async Task CreateAsync(Tenant tenant, CancellationToken cancellationToken = default) + public async Task CreateAsync(Tenant tenant, CancellationToken cancellationToken = default) { - return await _store.CreateAsync(tenant, cancellationToken); + return await store.CreateAsync(tenant, cancellationToken); } - public virtual async Task UpdateAsync(Tenant tenant, CancellationToken cancellationToken = default) + public async Task UpdateAsync(Tenant tenant, CancellationToken cancellationToken = default) { - return await _store.UpdateAsync(tenant, cancellationToken); + return await store.UpdateAsync(tenant, cancellationToken); } - public virtual async Task DeleteAsync(Tenant tenant, CancellationToken cancellationToken = default) + public async Task DeleteAsync(Tenant tenant, CancellationToken cancellationToken = default) { - return await _store.DeleteAsync(tenant, cancellationToken); + return await store.DeleteAsync(tenant, cancellationToken); } - public virtual async Task GetUserCountAsync(long tenantId, CancellationToken cancellationToken = default) + public async Task GetUserCountAsync(long tenantId, CancellationToken cancellationToken = default) { - return await _store.GetUserCountAsync(tenantId, cancellationToken); + return await store.GetUserCountAsync(tenantId, cancellationToken); } - public virtual async Task SetTenantCodeAsync(Tenant tenant, string code, CancellationToken cancellationToken = default) + public async Task SetTenantCodeAsync(Tenant tenant, string code, CancellationToken cancellationToken = default) { - await _store.SetTenantCodeAsync(tenant, code, cancellationToken); + await store.SetTenantCodeAsync(tenant, code, cancellationToken); return IdentityResult.Success; } }