fengling-platform/Fengling.Platform.Infrastructure/Repositories/TenantRepository.cs
movingsam d737688e9b feat(auth): extract Tenant to Platform domain
- Add Fengling.Platform domain and infrastructure projects
- Move Tenant aggregate from AuthService/Console to Platform.Domain
- Add TenantRepository and SeedData to Platform
- Remove duplicate Tenant/TenantInfo models from AuthService and Console
- Update controllers and services to use Platform.Domain.Tenant
- Add new migrations for PlatformDbContext

BREAKING CHANGE: Tenant entity now uses strongly-typed ID (TenantId)
2026-02-18 23:02:03 +08:00

28 lines
1.1 KiB
C#

using NetCorePal.Extensions.Repository.EntityFrameworkCore;
namespace Fengling.Platform.Infrastructure.Repositories;
using Fengling.Platform.Domain.AggregatesModel.TenantAggregate;
using NetCorePal.Extensions.Repository;
using Microsoft.EntityFrameworkCore;
public interface ITenantRepository : IRepository<Tenant, TenantId>
{
Task<Tenant?> GetByTenantIdAsync(string tenantId, CancellationToken cancellationToken = default);
Task<Tenant?> GetByIdIncludeH5Async(TenantId id, CancellationToken cancellationToken = default);
}
public class TenantRepository(PlatformDbContext context)
: RepositoryBase<Tenant, TenantId, PlatformDbContext>(context), ITenantRepository
{
public async Task<Tenant?> GetByTenantIdAsync(string tenantId, CancellationToken cancellationToken = default)
{
return await DbContext.Tenants.FirstOrDefaultAsync(t => t.TenantCode == tenantId, cancellationToken);
}
public async Task<Tenant?> GetByIdIncludeH5Async(TenantId id, CancellationToken cancellationToken = default)
{
return await DbContext.Tenants.FirstOrDefaultAsync(t => t.Id == id, cancellationToken);
}
}