6 changed files with 286 additions and 1 deletions
@ -0,0 +1,13 @@ |
|||||
|
using Volo.Abp.Collections; |
||||
|
|
||||
|
namespace LINGYUN.Abp.SettingManagement; |
||||
|
public class SettingManagementMergeOptions |
||||
|
{ |
||||
|
public ITypeList<IUserSettingAppService> UserSettingProviders { get; } |
||||
|
public ITypeList<IReadonlySettingAppService> GlobalSettingProviders { get; } |
||||
|
public SettingManagementMergeOptions() |
||||
|
{ |
||||
|
UserSettingProviders = new TypeList<IUserSettingAppService>(); |
||||
|
GlobalSettingProviders = new TypeList<IReadonlySettingAppService>(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,70 @@ |
|||||
|
using LINGYUN.Abp.SettingManagement; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.Extensions.Options; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace LY.MicroService.Applications.Single.Controllers; |
||||
|
|
||||
|
[ExposeServices( |
||||
|
typeof(SettingController), |
||||
|
typeof(SettingMergeController))] |
||||
|
public class SettingMergeController : SettingController |
||||
|
{ |
||||
|
private readonly SettingManagementMergeOptions _mergeOptions; |
||||
|
public SettingMergeController( |
||||
|
ISettingAppService settingAppService, |
||||
|
ISettingTestAppService settingTestAppService, |
||||
|
IOptions<SettingManagementMergeOptions> mergeOptions) |
||||
|
: base(settingAppService, settingTestAppService) |
||||
|
{ |
||||
|
_mergeOptions = mergeOptions.Value; |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("by-current-tenant")] |
||||
|
public async override Task<SettingGroupResult> GetAllForCurrentTenantAsync() |
||||
|
{ |
||||
|
var result = new SettingGroupResult(); |
||||
|
var markTypeMap = new List<Type> |
||||
|
{ |
||||
|
typeof(SettingMergeController), |
||||
|
}; |
||||
|
foreach (var serviceType in _mergeOptions.GlobalSettingProviders |
||||
|
.Where(type => !markTypeMap.Any(markType => type.IsAssignableFrom(markType)))) |
||||
|
{ |
||||
|
var settingService = LazyServiceProvider.LazyGetRequiredService(serviceType).As<IReadonlySettingAppService>(); |
||||
|
var currentResult = await settingService.GetAllForCurrentTenantAsync(); |
||||
|
foreach (var group in currentResult.Items) |
||||
|
{ |
||||
|
result.AddGroup(group); |
||||
|
} |
||||
|
markTypeMap.Add(serviceType); |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("by-global")] |
||||
|
public async override Task<SettingGroupResult> GetAllForGlobalAsync() |
||||
|
{ |
||||
|
var result = new SettingGroupResult(); |
||||
|
var markTypeMap = new List<Type> |
||||
|
{ |
||||
|
typeof(SettingMergeController), |
||||
|
}; |
||||
|
foreach (var serviceType in _mergeOptions.GlobalSettingProviders |
||||
|
.Where(type => !markTypeMap.Any(markType => type.IsAssignableFrom(markType)))) |
||||
|
{ |
||||
|
var settingService = LazyServiceProvider.LazyGetRequiredService(serviceType).As<IReadonlySettingAppService>(); |
||||
|
var currentResult = await settingService.GetAllForGlobalAsync(); |
||||
|
foreach (var group in currentResult.Items) |
||||
|
{ |
||||
|
result.AddGroup(group); |
||||
|
} |
||||
|
markTypeMap.Add(serviceType); |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,45 @@ |
|||||
|
using LINGYUN.Abp.SettingManagement; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.Extensions.Options; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace LY.MicroService.Applications.Single.Controllers; |
||||
|
|
||||
|
[ExposeServices( |
||||
|
typeof(UserSettingController), |
||||
|
typeof(UserSettingMergeController))] |
||||
|
public class UserSettingMergeController : UserSettingController |
||||
|
{ |
||||
|
private readonly SettingManagementMergeOptions _mergeOptions; |
||||
|
public UserSettingMergeController( |
||||
|
IUserSettingAppService service, |
||||
|
IOptions<SettingManagementMergeOptions> mergeOptions) |
||||
|
: base(service) |
||||
|
{ |
||||
|
_mergeOptions = mergeOptions.Value; |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("by-current-user")] |
||||
|
public async override Task<SettingGroupResult> GetAllForCurrentUserAsync() |
||||
|
{ |
||||
|
var result = new SettingGroupResult(); |
||||
|
var markTypeMap = new List<Type> |
||||
|
{ |
||||
|
typeof(UserSettingMergeController), |
||||
|
}; |
||||
|
foreach (var serviceType in _mergeOptions.UserSettingProviders |
||||
|
.Where(type => !markTypeMap.Any(markType => type.IsAssignableFrom(markType)))) |
||||
|
{ |
||||
|
var settingService = LazyServiceProvider.LazyGetRequiredService(serviceType).As<IUserSettingAppService>(); |
||||
|
var currentResult = await settingService.GetAllForCurrentUserAsync(); |
||||
|
foreach (var group in currentResult.Items) |
||||
|
{ |
||||
|
result.AddGroup(group); |
||||
|
} |
||||
|
markTypeMap.Add(serviceType); |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,74 @@ |
|||||
|
using LINGYUN.Abp.SettingManagement; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.Extensions.Options; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace LY.MicroService.BackendAdmin.Controllers; |
||||
|
|
||||
|
[ExposeServices( |
||||
|
typeof(SettingController), |
||||
|
typeof(SettingMergeController))] |
||||
|
public class SettingMergeController : SettingController |
||||
|
{ |
||||
|
private readonly SettingManagementMergeOptions _mergeOptions; |
||||
|
public SettingMergeController( |
||||
|
ISettingAppService settingAppService, |
||||
|
ISettingTestAppService settingTestAppService, |
||||
|
IOptions<SettingManagementMergeOptions> mergeOptions) |
||||
|
: base(settingAppService, settingTestAppService) |
||||
|
{ |
||||
|
_mergeOptions = mergeOptions.Value; |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("by-current-tenant")] |
||||
|
public async override Task<SettingGroupResult> GetAllForCurrentTenantAsync() |
||||
|
{ |
||||
|
var result = new SettingGroupResult(); |
||||
|
var markTypeMap = new List<Type> |
||||
|
{ |
||||
|
typeof(SettingMergeController), |
||||
|
}; |
||||
|
foreach (var serviceType in _mergeOptions.GlobalSettingProviders |
||||
|
.Where(type => !markTypeMap.Any(markType => type.IsAssignableFrom(markType)))) |
||||
|
{ |
||||
|
var settingService = LazyServiceProvider.LazyGetRequiredService(serviceType).As<IReadonlySettingAppService>(); |
||||
|
var currentResult = await settingService.GetAllForCurrentTenantAsync(); |
||||
|
foreach (var group in currentResult.Items) |
||||
|
{ |
||||
|
result.AddGroup(group); |
||||
|
} |
||||
|
markTypeMap.Add(serviceType); |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("by-global")] |
||||
|
public async override Task<SettingGroupResult> GetAllForGlobalAsync() |
||||
|
{ |
||||
|
var result = new SettingGroupResult(); |
||||
|
var markTypeMap = new List<Type> |
||||
|
{ |
||||
|
typeof(SettingMergeController), |
||||
|
}; |
||||
|
foreach (var serviceType in _mergeOptions.GlobalSettingProviders |
||||
|
.Where(type => !markTypeMap.Any(markType => type.IsAssignableFrom(markType)))) |
||||
|
{ |
||||
|
var settingService = LazyServiceProvider.LazyGetRequiredService(serviceType).As<IReadonlySettingAppService>(); |
||||
|
var currentResult = await settingService.GetAllForGlobalAsync(); |
||||
|
foreach (var group in currentResult.Items) |
||||
|
{ |
||||
|
result.AddGroup(group); |
||||
|
} |
||||
|
markTypeMap.Add(serviceType); |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,49 @@ |
|||||
|
using LINGYUN.Abp.SettingManagement; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.Extensions.Options; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace LY.MicroService.BackendAdmin.Controllers; |
||||
|
|
||||
|
[ExposeServices( |
||||
|
typeof(UserSettingController), |
||||
|
typeof(UserSettingMergeController))] |
||||
|
public class UserSettingMergeController : UserSettingController |
||||
|
{ |
||||
|
private readonly SettingManagementMergeOptions _mergeOptions; |
||||
|
public UserSettingMergeController( |
||||
|
IUserSettingAppService service, |
||||
|
IOptions<SettingManagementMergeOptions> mergeOptions) |
||||
|
: base(service) |
||||
|
{ |
||||
|
_mergeOptions = mergeOptions.Value; |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("by-current-user")] |
||||
|
public async override Task<SettingGroupResult> GetAllForCurrentUserAsync() |
||||
|
{ |
||||
|
var result = new SettingGroupResult(); |
||||
|
var markTypeMap = new List<Type> |
||||
|
{ |
||||
|
typeof(UserSettingMergeController), |
||||
|
}; |
||||
|
foreach (var serviceType in _mergeOptions.UserSettingProviders |
||||
|
.Where(type => !markTypeMap.Any(markType => type.IsAssignableFrom(markType)))) |
||||
|
{ |
||||
|
var settingService = LazyServiceProvider.LazyGetRequiredService(serviceType).As<IUserSettingAppService>(); |
||||
|
var currentResult = await settingService.GetAllForCurrentUserAsync(); |
||||
|
foreach (var group in currentResult.Items) |
||||
|
{ |
||||
|
result.AddGroup(group); |
||||
|
} |
||||
|
markTypeMap.Add(serviceType); |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue