|
|
@ -3,6 +3,8 @@ using System.Collections.Generic; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
using Volo.Abp.Application.Dtos; |
|
|
using Volo.Abp.Application.Dtos; |
|
|
|
|
|
using Volo.Abp.AspNetCore.Mvc.MultiTenancy; |
|
|
|
|
|
using Volo.Abp.Caching; |
|
|
using Volo.Abp.Data; |
|
|
using Volo.Abp.Data; |
|
|
using Volo.Abp.EventBus.Distributed; |
|
|
using Volo.Abp.EventBus.Distributed; |
|
|
using Volo.Abp.MultiTenancy; |
|
|
using Volo.Abp.MultiTenancy; |
|
|
@ -17,17 +19,20 @@ public class TenantAppService : TenantManagementAppServiceBase, ITenantAppServic |
|
|
protected ITenantRepository TenantRepository { get; } |
|
|
protected ITenantRepository TenantRepository { get; } |
|
|
protected ITenantManager TenantManager { get; } |
|
|
protected ITenantManager TenantManager { get; } |
|
|
protected IDistributedEventBus DistributedEventBus { get; } |
|
|
protected IDistributedEventBus DistributedEventBus { get; } |
|
|
|
|
|
protected IDistributedCache<TenantConfiguration> TenantConfigurationCache { get; } |
|
|
|
|
|
|
|
|
public TenantAppService( |
|
|
public TenantAppService( |
|
|
ITenantRepository tenantRepository, |
|
|
ITenantRepository tenantRepository, |
|
|
ITenantManager tenantManager, |
|
|
ITenantManager tenantManager, |
|
|
IDataSeeder dataSeeder, |
|
|
IDataSeeder dataSeeder, |
|
|
IDistributedEventBus distributedEventBus) |
|
|
IDistributedEventBus distributedEventBus, |
|
|
|
|
|
IDistributedCache<TenantConfiguration> tenantConfigurationCache) |
|
|
{ |
|
|
{ |
|
|
DataSeeder = dataSeeder; |
|
|
DataSeeder = dataSeeder; |
|
|
TenantRepository = tenantRepository; |
|
|
TenantRepository = tenantRepository; |
|
|
TenantManager = tenantManager; |
|
|
TenantManager = tenantManager; |
|
|
DistributedEventBus = distributedEventBus; |
|
|
DistributedEventBus = distributedEventBus; |
|
|
|
|
|
TenantConfigurationCache = tenantConfigurationCache; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public virtual async Task<TenantDto> GetAsync(Guid id) |
|
|
public virtual async Task<TenantDto> GetAsync(Guid id) |
|
|
@ -91,6 +96,9 @@ public class TenantAppService : TenantManagementAppServiceBase, ITenantAppServic |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await TenantConfigurationCache.RemoveAsync(TenantConfigurationCacheHelper.CreateCacheKey(tenant.Id)); |
|
|
|
|
|
await TenantConfigurationCache.RemoveAsync(TenantConfigurationCacheHelper.CreateCacheKey(tenant.Name)); |
|
|
|
|
|
|
|
|
return ObjectMapper.Map<Tenant, TenantDto>(tenant); |
|
|
return ObjectMapper.Map<Tenant, TenantDto>(tenant); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -106,6 +114,9 @@ public class TenantAppService : TenantManagementAppServiceBase, ITenantAppServic |
|
|
|
|
|
|
|
|
await TenantRepository.UpdateAsync(tenant); |
|
|
await TenantRepository.UpdateAsync(tenant); |
|
|
|
|
|
|
|
|
|
|
|
await TenantConfigurationCache.RemoveAsync(TenantConfigurationCacheHelper.CreateCacheKey(tenant.Id)); |
|
|
|
|
|
await TenantConfigurationCache.RemoveAsync(TenantConfigurationCacheHelper.CreateCacheKey(tenant.Name)); |
|
|
|
|
|
|
|
|
return ObjectMapper.Map<Tenant, TenantDto>(tenant); |
|
|
return ObjectMapper.Map<Tenant, TenantDto>(tenant); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -119,6 +130,9 @@ public class TenantAppService : TenantManagementAppServiceBase, ITenantAppServic |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
await TenantRepository.DeleteAsync(tenant); |
|
|
await TenantRepository.DeleteAsync(tenant); |
|
|
|
|
|
|
|
|
|
|
|
await TenantConfigurationCache.RemoveAsync(TenantConfigurationCacheHelper.CreateCacheKey(tenant.Id)); |
|
|
|
|
|
await TenantConfigurationCache.RemoveAsync(TenantConfigurationCacheHelper.CreateCacheKey(tenant.Name)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Authorize(TenantManagementPermissions.Tenants.ManageConnectionStrings)] |
|
|
[Authorize(TenantManagementPermissions.Tenants.ManageConnectionStrings)] |
|
|
|