- 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)
28 lines
1.1 KiB
C#
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);
|
|
}
|
|
}
|