Browse Source
Merge pull request #19242 from abpframework/auto-merge/rel-8-1/2564
Merge branch dev with rel-8.1
pull/19244/head
maliming
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with
42 additions and
0 deletions
-
framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/MauiBlazorRemoteTenantStore.cs
-
framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcRemoteTenantStore.cs
-
framework/src/Volo.Abp.MultiTenancy.Abstractions/Volo/Abp/MultiTenancy/ITenantStore.cs
-
framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/ConfigurationStore/DefaultTenantStore.cs
-
modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/AbpTenantManagementDomainMappingProfile.cs
-
modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/TenantStore.cs
-
modules/tenant-management/test/Volo.Abp.TenantManagement.Domain.Tests/Volo/Abp/TenantManagement/TenantStore_Tests.cs
|
|
|
@ -1,4 +1,5 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.Extensions.Caching.Distributed; |
|
|
|
using Pages.Abp.MultiTenancy.ClientProxies; |
|
|
|
@ -57,6 +58,11 @@ public class MauiBlazorRemoteTenantStore : ITenantStore, ITransientDependency |
|
|
|
return tenantConfiguration; |
|
|
|
} |
|
|
|
|
|
|
|
public Task<IReadOnlyList<TenantConfiguration>> GetListAsync(bool includeDetails = false) |
|
|
|
{ |
|
|
|
return Task.FromResult<IReadOnlyList<TenantConfiguration>>(Array.Empty<TenantConfiguration>()); |
|
|
|
} |
|
|
|
|
|
|
|
public TenantConfiguration? Find(string normalizedName) |
|
|
|
{ |
|
|
|
var cacheKey = CreateCacheKey(normalizedName); |
|
|
|
|
|
|
|
@ -1,4 +1,5 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
@ -79,6 +80,11 @@ public class MvcRemoteTenantStore : ITenantStore, ITransientDependency |
|
|
|
return tenantConfiguration?.Value; |
|
|
|
} |
|
|
|
|
|
|
|
public Task<IReadOnlyList<TenantConfiguration>> GetListAsync(bool includeDetails = false) |
|
|
|
{ |
|
|
|
return Task.FromResult<IReadOnlyList<TenantConfiguration>>(Array.Empty<TenantConfiguration>()); |
|
|
|
} |
|
|
|
|
|
|
|
public TenantConfiguration? Find(string normalizedName) |
|
|
|
{ |
|
|
|
var cacheKey = TenantConfigurationCacheItem.CalculateCacheKey(normalizedName); |
|
|
|
|
|
|
|
@ -1,4 +1,5 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
namespace Volo.Abp.MultiTenancy; |
|
|
|
@ -9,6 +10,8 @@ public interface ITenantStore |
|
|
|
|
|
|
|
Task<TenantConfiguration?> FindAsync(Guid id); |
|
|
|
|
|
|
|
Task<IReadOnlyList<TenantConfiguration>> GetListAsync(bool includeDetails = false); |
|
|
|
|
|
|
|
[Obsolete("Use FindAsync method.")] |
|
|
|
TenantConfiguration? Find(string normalizedName); |
|
|
|
|
|
|
|
|
|
|
|
@ -1,4 +1,5 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
@ -26,6 +27,11 @@ public class DefaultTenantStore : ITenantStore, ITransientDependency |
|
|
|
return Task.FromResult(Find(id)); |
|
|
|
} |
|
|
|
|
|
|
|
public Task<IReadOnlyList<TenantConfiguration>> GetListAsync(bool includeDetails = false) |
|
|
|
{ |
|
|
|
return Task.FromResult<IReadOnlyList<TenantConfiguration>>(_options.Tenants); |
|
|
|
} |
|
|
|
|
|
|
|
public TenantConfiguration? Find(string normalizedName) |
|
|
|
{ |
|
|
|
return _options.Tenants?.FirstOrDefault(t => t.NormalizedName == normalizedName); |
|
|
|
|
|
|
|
@ -15,6 +15,11 @@ public class AbpTenantManagementDomainMappingProfile : Profile |
|
|
|
{ |
|
|
|
var connStrings = new ConnectionStrings(); |
|
|
|
|
|
|
|
if (tenant.ConnectionStrings == null) |
|
|
|
{ |
|
|
|
return connStrings; |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var connectionString in tenant.ConnectionStrings) |
|
|
|
{ |
|
|
|
connStrings[connectionString.Name] = connectionString.Value; |
|
|
|
|
|
|
|
@ -1,4 +1,5 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using JetBrains.Annotations; |
|
|
|
using Volo.Abp.Caching; |
|
|
|
@ -37,6 +38,12 @@ public class TenantStore : ITenantStore, ITransientDependency |
|
|
|
return (await GetCacheItemAsync(id, null)).Value; |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<IReadOnlyList<TenantConfiguration>> GetListAsync(bool includeDetails = false) |
|
|
|
{ |
|
|
|
return ObjectMapper.Map<List<Tenant>, List<TenantConfiguration>>( |
|
|
|
await TenantRepository.GetListAsync(includeDetails)); |
|
|
|
} |
|
|
|
|
|
|
|
[Obsolete("Use FindAsync method.")] |
|
|
|
public virtual TenantConfiguration Find(string normalizedName) |
|
|
|
{ |
|
|
|
|
|
|
|
@ -35,4 +35,13 @@ public class TenantStore_Tests : AbpTenantManagementDomainTestBase |
|
|
|
|
|
|
|
(await _tenantStore.FindAsync(acme.Id)).ShouldNotBeNull(); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task GetListAsync() |
|
|
|
{ |
|
|
|
var tenants = await _tenantRepository.GetListAsync(); |
|
|
|
|
|
|
|
tenants.ShouldNotBeNull(); |
|
|
|
tenants.Count.ShouldBe(3); |
|
|
|
} |
|
|
|
} |
|
|
|
|