734b2c91f9
1. 将Hua.Cli.Tests、项目共享库、模块项目等所有项目的TargetFramework从net8.0/net9.0升级到net10.0 2. 完善dotnet-tools.json、模板配置文件,添加必要的构建和发布配置 3. 新增微服务、网关、应用程序的启动脚本和基础配置文件 4. 补充产品管理模块的领域、应用、Web层基础代码和多语言资源
38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
using System.Threading.Tasks;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
|
using Volo.Abp.Data;
|
|
using Volo.Abp.DependencyInjection;
|
|
using Volo.Abp.Domain.Entities.Events.Distributed;
|
|
using Volo.Abp.EventBus.Distributed;
|
|
using Volo.Abp.MultiTenancy;
|
|
using Volo.Abp.TenantManagement;
|
|
|
|
namespace Company.Project.IdentityService.Tenants;
|
|
|
|
public class TenantCreatedDistributedEventHandler : IDistributedEventHandler<EntityCreatedEto<TenantEto>>, ITransientDependency
|
|
{
|
|
public ILogger<TenantCreatedDistributedEventHandler> Logger { get; set; }
|
|
private readonly IDataSeeder _dataSeeder;
|
|
private readonly ICurrentTenant _currentTenant;
|
|
|
|
public TenantCreatedDistributedEventHandler(
|
|
IDataSeeder dataSeeder,
|
|
ICurrentTenant currentTenant)
|
|
{
|
|
_dataSeeder = dataSeeder;
|
|
_currentTenant = currentTenant;
|
|
Logger = NullLogger<TenantCreatedDistributedEventHandler>.Instance;
|
|
}
|
|
|
|
public async Task HandleEventAsync(EntityCreatedEto<TenantEto> eventData)
|
|
{
|
|
Logger.LogInformation($"Handled distributed event for a new tenant creation. TenantId: {eventData.Entity.Id}");
|
|
|
|
using (_currentTenant.Change(eventData.Entity.Id, eventData.Entity.Name))
|
|
{
|
|
await _dataSeeder.SeedAsync(tenantId: eventData.Entity.Id);
|
|
}
|
|
}
|
|
}
|