Browse Source

Merge pull request #335 from colinin/4.4

fix(tenant): fix the inconsistent tenant service name
pull/364/head
yx lin 4 years ago
committed by GitHub
parent
commit
1cda09a45b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      aspnet-core/LINGYUN.MicroService.BackendAdmin.sln
  2. 4
      aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN.Abp.MultiTenancy.DbFinder.csproj
  3. 9
      aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN/Abp/MultiTenancy/DbFinder/EventBus/Distributed/TenantCreateEventHandler.cs
  4. 7
      aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN/Abp/MultiTenancy/DbFinder/EventBus/Distributed/TenantDeleteEventHandler.cs
  5. 9
      aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN/Abp/MultiTenancy/DbFinder/EventBus/Distributed/TenantUpdateEventHandler.cs
  6. 4
      aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/README.md
  7. 1
      aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.RemoteService/LINGYUN.Abp.MultiTenancy.RemoteService.csproj
  8. 9
      aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.RemoteService/LINGYUN/Abp/MultiTenancy/RemoteService/EventBus/Distributed/TenantCreateEventHandler.cs
  9. 7
      aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.RemoteService/LINGYUN/Abp/MultiTenancy/RemoteService/EventBus/Distributed/TenantDeleteEventHandler.cs
  10. 9
      aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.RemoteService/LINGYUN/Abp/MultiTenancy/RemoteService/EventBus/Distributed/TenantUpdateEventHandler.cs
  11. 10
      aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.RemoteService/README.md
  12. 13
      aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy/LINGYUN/Abp/MultiTenancy/CreateConnectionStringEventData.cs
  13. 11
      aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy/LINGYUN/Abp/MultiTenancy/DeleteConnectionStringEventData.cs
  14. 9
      aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy/LINGYUN/Abp/MultiTenancy/DeleteEventData.cs
  15. 17
      aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy/LINGYUN/Abp/MultiTenancy/UpdateConnectionStringEventData.cs
  16. 13
      aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy/LINGYUN/Abp/MultiTenancy/UpdateEventData.cs
  17. 27
      aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.Application/LINGYUN/Abp/TenantManagement/TenantAppService.cs
  18. 4
      aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.HttpApi.Client/LINGYUN/Abp/TenantManagement/AbpTenantManagementHttpApiClientModule.cs

7
aspnet-core/LINGYUN.MicroService.BackendAdmin.sln

@ -69,6 +69,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WeChat.SettingM
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.Application.Contracts", "modules\oss-management\LINGYUN.Abp.OssManagement.Application.Contracts\LINGYUN.Abp.OssManagement.Application.Contracts.csproj", "{5C3D0A48-4EE3-4968-9826-5F52ADDC22C4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.MultiTenancy", "modules\tenants\LINGYUN.Abp.MultiTenancy\LINGYUN.Abp.MultiTenancy.csproj", "{360B5928-DD64-42AA-8C99-07EFC5224C24}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -167,6 +169,10 @@ Global
{5C3D0A48-4EE3-4968-9826-5F52ADDC22C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5C3D0A48-4EE3-4968-9826-5F52ADDC22C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5C3D0A48-4EE3-4968-9826-5F52ADDC22C4}.Release|Any CPU.Build.0 = Release|Any CPU
{360B5928-DD64-42AA-8C99-07EFC5224C24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{360B5928-DD64-42AA-8C99-07EFC5224C24}.Debug|Any CPU.Build.0 = Debug|Any CPU
{360B5928-DD64-42AA-8C99-07EFC5224C24}.Release|Any CPU.ActiveCfg = Release|Any CPU
{360B5928-DD64-42AA-8C99-07EFC5224C24}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -203,6 +209,7 @@ Global
{EAD2F955-88CA-4570-AB81-31FB2FF02605} = {B36F627B-FD7D-4357-A623-F01AFF78B80D}
{3FD9C35C-3A8D-49F5-B7C5-4828AA3407AB} = {B36F627B-FD7D-4357-A623-F01AFF78B80D}
{5C3D0A48-4EE3-4968-9826-5F52ADDC22C4} = {8F972C8E-F047-4883-A4BF-3423A2BAED36}
{360B5928-DD64-42AA-8C99-07EFC5224C24} = {CB1A2EB0-34D4-41C4-BF01-C99EFBBF09EE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1573B900-87BA-4AD3-B785-6DD78127ADEF}

4
aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN.Abp.MultiTenancy.DbFinder.csproj

@ -12,4 +12,8 @@
<PackageReference Include="Volo.Abp.TenantManagement.Domain" Version="4.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LINGYUN.Abp.MultiTenancy\LINGYUN.Abp.MultiTenancy.csproj" />
</ItemGroup>
</Project>

9
aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN/Abp/MultiTenancy/DbFinder/EventBus/Distributed/TenantCreateEventHandler.cs

@ -50,8 +50,13 @@ namespace LINGYUN.Abp.MultiTenancy.DbFinder.EventBus.Distributed
}
var cacheItem = new TenantConfigurationCacheItem(tenant.Id, tenant.Name, connectionStrings);
var cacheKey = TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Id.ToString());
await _cache.SetAsync(cacheKey, cacheItem);
await _cache.SetAsync(
TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Id.ToString()),
cacheItem);
await _cache.SetAsync(
TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Name),
cacheItem);
}
}
catch (Exception ex)

7
aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN/Abp/MultiTenancy/DbFinder/EventBus/Distributed/TenantDeleteEventHandler.cs

@ -19,8 +19,11 @@ namespace LINGYUN.Abp.MultiTenancy.DbFinder.EventBus.Distributed
public virtual async Task HandleEventAsync(EntityDeletedEto<TenantEto> eventData)
{
var cacheKey = TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Id.ToString());
await _cache.RemoveAsync(cacheKey);
await _cache.RemoveAsync(
TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Id.ToString()));
await _cache.RemoveAsync(
TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Name));
}
}
}

9
aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN/Abp/MultiTenancy/DbFinder/EventBus/Distributed/TenantUpdateEventHandler.cs

@ -50,8 +50,13 @@ namespace LINGYUN.Abp.MultiTenancy.DbFinder.EventBus.Distributed
}
var cacheItem = new TenantConfigurationCacheItem(tenant.Id, tenant.Name, connectionStrings);
var cacheKey = TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Id.ToString());
await _cache.SetAsync(cacheKey, cacheItem);
await _cache.SetAsync(
TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Id.ToString()),
cacheItem);
await _cache.SetAsync(
TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Name),
cacheItem);
}
}
catch(Exception ex)

4
aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/README.md

@ -12,10 +12,10 @@ abp 多租户数据库查询组件,引用此模块将首先从分布式缓存查
``` shell
// .NET CLI
dotnet add package Volo.Abp.TenantManagement.EntityFrameworkCore --version 3.0.0
dotnet add package Volo.Abp.TenantManagement.EntityFrameworkCore
// Package Manager
Install-Package Volo.Abp.TenantManagement.EntityFrameworkCore -Version 3.0.0
Install-Package Volo.Abp.TenantManagement.EntityFrameworkCore
```

1
aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.RemoteService/LINGYUN.Abp.MultiTenancy.RemoteService.csproj

@ -12,6 +12,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LINGYUN.Abp.MultiTenancy\LINGYUN.Abp.MultiTenancy.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.TenantManagement.HttpApi.Client\LINGYUN.Abp.TenantManagement.HttpApi.Client.csproj" />
</ItemGroup>

9
aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.RemoteService/LINGYUN/Abp/MultiTenancy/RemoteService/EventBus/Distributed/TenantCreateEventHandler.cs

@ -33,8 +33,13 @@ namespace LINGYUN.Abp.MultiTenancy.RemoteService.EventBus.Distributed
}
var cacheItem = new TenantConfigurationCacheItem(tenantDto.Id, tenantDto.Name, connectionStrings);
var cacheKey = TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Id.ToString());
await _cache.SetAsync(cacheKey, cacheItem);
await _cache.SetAsync(
TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Id.ToString()),
cacheItem);
await _cache.SetAsync(
TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Name),
cacheItem);
}
}
}

7
aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.RemoteService/LINGYUN/Abp/MultiTenancy/RemoteService/EventBus/Distributed/TenantDeleteEventHandler.cs

@ -19,8 +19,11 @@ namespace LINGYUN.Abp.MultiTenancy.RemoteService.EventBus.Distributed
public virtual async Task HandleEventAsync(EntityDeletedEto<TenantEto> eventData)
{
var cacheKey = TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Id.ToString());
await _cache.RemoveAsync(cacheKey);
await _cache.RemoveAsync(
TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Id.ToString()));
await _cache.RemoveAsync(
TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Name));
}
}
}

9
aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.RemoteService/LINGYUN/Abp/MultiTenancy/RemoteService/EventBus/Distributed/TenantUpdateEventHandler.cs

@ -33,8 +33,13 @@ namespace LINGYUN.Abp.MultiTenancy.RemoteService.EventBus.Distributed
}
var cacheItem = new TenantConfigurationCacheItem(tenantDto.Id, tenantDto.Name, connectionStrings);
var cacheKey = TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Id.ToString());
await _cache.SetAsync(cacheKey, cacheItem);
await _cache.SetAsync(
TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Id.ToString()),
cacheItem);
await _cache.SetAsync(
TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Name),
cacheItem);
}
}
}

10
aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.RemoteService/README.md

@ -12,10 +12,10 @@ abp 多租户远程服务组件,引用此模块将首先从分布式缓存查询
``` shell
// .NET CLI
dotnet add package Volo.Abp.Http.Client.IdentityModel --version 3.0.0
dotnet add package Volo.Abp.Http.Client.IdentityModel
// Package Manager
Install-Package Volo.Abp.Http.Client.IdentityModel -Version 3.0.0
Install-Package Volo.Abp.Http.Client.IdentityModel
```
@ -30,13 +30,13 @@ Install-Package Volo.Abp.Http.Client.IdentityModel -Version 3.0.0
```json
{
"RemoteServices": {
"TenantManagement": {
"AbpTenantManagement": {
"BaseUrl": "http://localhost:30000/",
"IdentityClient": "tenant-finder-client"
"IdentityClient": "InternalServiceClient"
}
},
"IdentityClients": {
"tenant-finder-client": {
"InternalServiceClient": {
"Authority": "http://localhost:44385",
"RequireHttps": false,
"GrantType": "client_credentials",

13
aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy/LINGYUN/Abp/MultiTenancy/CreateConnectionStringEventData.cs

@ -1,13 +0,0 @@
using System;
namespace LINGYUN.Abp.MultiTenancy
{
public class CreateConnectionStringEventData
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Value { get; set; }
}
}

11
aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy/LINGYUN/Abp/MultiTenancy/DeleteConnectionStringEventData.cs

@ -1,11 +0,0 @@
using System;
namespace LINGYUN.Abp.MultiTenancy
{
public class DeleteConnectionStringEventData
{
public Guid Id { get; set; }
public string Name { get; set; }
}
}

9
aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy/LINGYUN/Abp/MultiTenancy/DeleteEventData.cs

@ -1,9 +0,0 @@
using System;
namespace LINGYUN.Abp.MultiTenancy
{
public class DeleteEventData
{
public Guid Id { get; set; }
}
}

17
aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy/LINGYUN/Abp/MultiTenancy/UpdateConnectionStringEventData.cs

@ -1,17 +0,0 @@
using System;
namespace LINGYUN.Abp.MultiTenancy
{
public class UpdateConnectionStringEventData
{
public Guid Id { get; set; }
public string OriginName { get; set; }
public string Name { get; set; }
public string OriginValue { get; set; }
public string Value { get; set; }
}
}

13
aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy/LINGYUN/Abp/MultiTenancy/UpdateEventData.cs

@ -1,13 +0,0 @@
using System;
namespace LINGYUN.Abp.MultiTenancy
{
public class UpdateEventData
{
public Guid Id { get; set; }
public string OriginName { get; set; }
public string Name { get; set; }
}
}

27
aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.Application/LINGYUN/Abp/TenantManagement/TenantAppService.cs

@ -93,17 +93,11 @@ namespace LINGYUN.Abp.TenantManagement
public virtual async Task<TenantDto> UpdateAsync(Guid id, TenantUpdateDto input)
{
var tenant = await TenantRepository.GetAsync(id, false);
var updateEventData = new UpdateEventData
{
Id = tenant.Id,
OriginName = tenant.Name,
Name = input.Name
};
await TenantManager.ChangeNameAsync(tenant, input.Name);
input.MapExtraPropertiesTo(tenant);
await TenantRepository.UpdateAsync(tenant);
await EventBus.PublishAsync(updateEventData);
return ObjectMapper.Map<Tenant, TenantDto>(tenant);
}
@ -146,15 +140,14 @@ namespace LINGYUN.Abp.TenantManagement
{
var tenant = await TenantRepository.GetAsync(id);
tenant.SetConnectionString(tenantConnectionStringCreateOrUpdate.Name, tenantConnectionStringCreateOrUpdate.Value);
var updateEventData = new UpdateEventData
var eventData = new ConnectionStringChangedEventData
{
Id = tenant.Id,
OriginName = tenant.Name,
Name = tenant.Name
OriginName = tenantConnectionStringCreateOrUpdate.Name,
Name = tenantConnectionStringCreateOrUpdate.Name
};
// abp当前版本(3.0.0)在EntityChangeEventHelper中存在一个问题,无法发送框架默认的Eto,预计3.1.0修复
// 发送自定义的事件数据来确保缓存被更新
await EventBus.PublishAsync(updateEventData);
await EventBus.PublishAsync(eventData);
return new TenantConnectionStringDto
{
@ -170,13 +163,13 @@ namespace LINGYUN.Abp.TenantManagement
tenant.RemoveConnectionString(name);
var updateEventData = new UpdateEventData
var eventData = new ConnectionStringChangedEventData
{
Id = tenant.Id,
OriginName = tenant.Name,
Name = tenant.Name
OriginName = name,
Name = name
};
await EventBus.PublishAsync(updateEventData);
await EventBus.PublishAsync(eventData);
await TenantRepository.UpdateAsync(tenant);
}

4
aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.HttpApi.Client/LINGYUN/Abp/TenantManagement/AbpTenantManagementHttpApiClientModule.cs

@ -9,13 +9,11 @@ namespace LINGYUN.Abp.TenantManagement
typeof(AbpHttpClientModule))]
public class AbpTenantManagementHttpApiClientModule : AbpModule
{
public const string RemoteServiceName = "TenantManagement";
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddHttpClientProxies(
typeof(AbpTenantManagementApplicationContractsModule).Assembly,
RemoteServiceName
TenantManagementRemoteServiceConsts.RemoteServiceName
);
}
}

Loading…
Cancel
Save