77 changed files with 1782 additions and 174 deletions
@ -0,0 +1,9 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
|
||||
|
namespace LINGYUN.Abp.SettingManagement; |
||||
|
|
||||
|
public interface IReadonlySettingV2AppService : IApplicationService |
||||
|
{ |
||||
|
Task<SettingGroupResult> GetAsync(); |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace LINGYUN.Abp.SettingManagement; |
||||
|
|
||||
|
public interface ISettingV2AppService : IReadonlySettingV2AppService |
||||
|
{ |
||||
|
Task SetAsync(UpdateSettingsDto input); |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
|
||||
|
namespace LINGYUN.Abp.SettingManagement; |
||||
|
|
||||
|
public interface IUserSettingV2AppService : IApplicationService |
||||
|
{ |
||||
|
Task SetAsync(UpdateSettingsDto input); |
||||
|
|
||||
|
Task<SettingGroupResult> GetAsync(); |
||||
|
} |
||||
@ -0,0 +1,314 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using Volo.Abp.Localization; |
||||
|
|
||||
|
namespace Volo.Abp.Settings; |
||||
|
|
||||
|
public static class SettingDefinitionExtensions |
||||
|
{ |
||||
|
private const string GroupKey = "Group"; |
||||
|
private const string ParentKey = "Parent"; |
||||
|
private const string OrderKey = "Order"; |
||||
|
private const string SlotKey = "Slot"; |
||||
|
private const string ValueTypeKey = "ValueType"; |
||||
|
private const string OptionNameKey = "OptionNames"; |
||||
|
private const string OptionValueKey = "OptionValues"; |
||||
|
private const string RequiredFeaturesKey = "RequiredFeatures"; |
||||
|
private const string RequiredPermissionsKey = "RequiredPermissions"; |
||||
|
|
||||
|
public static SettingDefinition RequiredFeatures( |
||||
|
this SettingDefinition definition, |
||||
|
IEnumerable<string> requiredFeatures) |
||||
|
{ |
||||
|
var existsRequiredFeatures = definition.GetRequiredFeatures(); |
||||
|
return definition |
||||
|
.WithProperty(RequiredFeaturesKey, existsRequiredFeatures.Union(requiredFeatures).JoinAsString(",")); |
||||
|
} |
||||
|
|
||||
|
public static SettingDefinition RequiredPermissions( |
||||
|
this SettingDefinition definition, |
||||
|
IEnumerable<string> requiredPermissions) |
||||
|
{ |
||||
|
var existsRequiredPermissions = definition.GetRequiredPermissions(); |
||||
|
return definition |
||||
|
.WithProperty(RequiredPermissionsKey, existsRequiredPermissions.Union(requiredPermissions).JoinAsString(",")); |
||||
|
} |
||||
|
|
||||
|
public static SettingDefinition WithSlot( |
||||
|
this SettingDefinition definition, |
||||
|
string slotName) |
||||
|
{ |
||||
|
return definition |
||||
|
.WithProperty(SlotKey, slotName); |
||||
|
} |
||||
|
|
||||
|
public static SettingDefinition WithValueType( |
||||
|
this SettingDefinition definition, |
||||
|
ValueType valueType) |
||||
|
{ |
||||
|
return definition |
||||
|
.WithProperty(ValueTypeKey, valueType.ToString()); |
||||
|
} |
||||
|
|
||||
|
public static SettingDefinition WithOrder( |
||||
|
this SettingDefinition definition, |
||||
|
int order) |
||||
|
{ |
||||
|
return definition |
||||
|
.WithProperty(OrderKey, order.ToString()); |
||||
|
} |
||||
|
|
||||
|
public static SettingDefinition WithGroup( |
||||
|
this SettingDefinition definition, |
||||
|
string name, |
||||
|
string displayName, |
||||
|
int order = 0, |
||||
|
string[]? requiredFeatures = null, |
||||
|
string[]? requiredPermissions = null) |
||||
|
{ |
||||
|
var groupDefinition = new SettingResourceDefinition( |
||||
|
name, |
||||
|
new FixedLocalizableString(displayName), |
||||
|
order, |
||||
|
requiredFeatures, |
||||
|
requiredPermissions); |
||||
|
|
||||
|
return definition |
||||
|
.WithProperty(GroupKey, groupDefinition.ToString()); |
||||
|
} |
||||
|
|
||||
|
public static SettingDefinition WithGroup( |
||||
|
this SettingDefinition definition, |
||||
|
string name, |
||||
|
LocalizableString displayName, |
||||
|
int order = 0, |
||||
|
string[]? requiredFeatures = null, |
||||
|
string[]? requiredPermissions = null) |
||||
|
{ |
||||
|
var groupDefinition = new SettingResourceDefinition( |
||||
|
name, |
||||
|
displayName, |
||||
|
order, |
||||
|
requiredFeatures, |
||||
|
requiredPermissions); |
||||
|
|
||||
|
return definition |
||||
|
.WithProperty(GroupKey, groupDefinition.ToString()); |
||||
|
} |
||||
|
|
||||
|
public static SettingDefinition RequiredGroupFeatures( |
||||
|
this SettingDefinition definition, |
||||
|
string[] requiredFeatures) |
||||
|
{ |
||||
|
var groupResource = definition.GetGroupOrNull(); |
||||
|
if (groupResource != null) |
||||
|
{ |
||||
|
groupResource.RequiredFeatures = requiredFeatures |
||||
|
.Union(groupResource.RequiredFeatures ?? []) |
||||
|
.ToArray(); |
||||
|
|
||||
|
return definition |
||||
|
.WithProperty(GroupKey, groupResource.ToString()); |
||||
|
} |
||||
|
|
||||
|
return definition; |
||||
|
} |
||||
|
|
||||
|
public static SettingDefinition RequiredGroupPermissions( |
||||
|
this SettingDefinition definition, |
||||
|
string[] requiredPermissions) |
||||
|
{ |
||||
|
var groupResource = definition.GetGroupOrNull(); |
||||
|
if (groupResource != null) |
||||
|
{ |
||||
|
groupResource.RequiredPermissions = requiredPermissions |
||||
|
.Union(groupResource.RequiredPermissions ?? []) |
||||
|
.ToArray(); |
||||
|
|
||||
|
return definition |
||||
|
.WithProperty(GroupKey, groupResource.ToString()); |
||||
|
} |
||||
|
|
||||
|
return definition; |
||||
|
} |
||||
|
|
||||
|
public static SettingDefinition WithParent( |
||||
|
this SettingDefinition definition, |
||||
|
string name, |
||||
|
string displayName, |
||||
|
int order = 0, |
||||
|
string[]? requiredFeatures = null, |
||||
|
string[]? requiredPermissions = null) |
||||
|
{ |
||||
|
var parentDefinition = new SettingResourceDefinition( |
||||
|
name, |
||||
|
new FixedLocalizableString(displayName), |
||||
|
order, |
||||
|
requiredFeatures, |
||||
|
requiredPermissions); |
||||
|
|
||||
|
return definition |
||||
|
.WithProperty(ParentKey, parentDefinition.ToString()); |
||||
|
} |
||||
|
|
||||
|
public static SettingDefinition WithParent( |
||||
|
this SettingDefinition definition, |
||||
|
string name, |
||||
|
LocalizableString displayName, |
||||
|
int order = 0, |
||||
|
string[]? requiredFeatures = null, |
||||
|
string[]? requiredPermissions = null) |
||||
|
{ |
||||
|
var parentDefinition = new SettingResourceDefinition( |
||||
|
name, |
||||
|
displayName, |
||||
|
order, |
||||
|
requiredFeatures, |
||||
|
requiredPermissions); |
||||
|
|
||||
|
return definition |
||||
|
.WithProperty(ParentKey, parentDefinition.ToString()); |
||||
|
} |
||||
|
|
||||
|
public static SettingDefinition WithOptions( |
||||
|
this SettingDefinition definition, |
||||
|
IEnumerable<NameValue<string>> options) |
||||
|
{ |
||||
|
var optionNames = options.Select(x => x.Name).JoinAsString(","); |
||||
|
var optionValues = options.Select(x => x.Value).JoinAsString(","); |
||||
|
|
||||
|
return definition |
||||
|
.WithValueType(ValueType.Option) |
||||
|
.WithProperty(OptionNameKey, optionNames) |
||||
|
.WithProperty(OptionValueKey, optionValues); |
||||
|
} |
||||
|
|
||||
|
public static SettingDefinition ReplaceProviders( |
||||
|
this SettingDefinition definition, |
||||
|
params string[] providers) |
||||
|
{ |
||||
|
definition.Providers.Clear(); |
||||
|
|
||||
|
return definition.WithProviders(providers); |
||||
|
} |
||||
|
|
||||
|
public static string? GetSlotOrNull(this SettingDefinition definition) |
||||
|
{ |
||||
|
if (definition.Properties.TryGetValue(SlotKey, out var slot) && slot != null) |
||||
|
{ |
||||
|
return slot.ToString(); |
||||
|
} |
||||
|
|
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
public static ValueType GetValueTypeOrDefault(this SettingDefinition definition, ValueType defaultValueType = ValueType.String) |
||||
|
{ |
||||
|
if (definition.Properties.TryGetValue(ValueTypeKey, out var valueTypeStr) && valueTypeStr != null && |
||||
|
Enum.TryParse<ValueType>(valueTypeStr.ToString(), out var valueType)) |
||||
|
{ |
||||
|
return valueType; |
||||
|
} |
||||
|
|
||||
|
return defaultValueType; |
||||
|
} |
||||
|
|
||||
|
public static SettingResourceDefinition? GetGroupOrNull(this SettingDefinition definition) |
||||
|
{ |
||||
|
return GetResourceOrNull(definition, GroupKey); |
||||
|
} |
||||
|
|
||||
|
public static SettingResourceDefinition? GetParentOrNull(this SettingDefinition definition) |
||||
|
{ |
||||
|
return GetResourceOrNull(definition, ParentKey); |
||||
|
} |
||||
|
|
||||
|
public static IEnumerable<NameValue<string>> GetOptions(this SettingDefinition definition) |
||||
|
{ |
||||
|
if (definition.TryGetArrayProperties(OptionNameKey, out var optionNames) && |
||||
|
definition.TryGetArrayProperties(OptionValueKey, out var optionValues)) |
||||
|
{ |
||||
|
return optionNames.Select((name, index) => |
||||
|
{ |
||||
|
return new NameValue<string>(name, optionValues[index]); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
return []; |
||||
|
} |
||||
|
|
||||
|
public static IEnumerable<string> GetRequiredFeatures(this SettingDefinition definition) |
||||
|
{ |
||||
|
definition.TryGetArrayProperties(RequiredFeaturesKey, out var requiredFeatures); |
||||
|
return requiredFeatures; |
||||
|
} |
||||
|
|
||||
|
public static IEnumerable<string> GetRequiredPermissions(this SettingDefinition definition) |
||||
|
{ |
||||
|
definition.TryGetArrayProperties(RequiredPermissionsKey, out var requiredPermissions); |
||||
|
return requiredPermissions; |
||||
|
} |
||||
|
|
||||
|
private static bool TryGetArrayProperties(this SettingDefinition definition, string propertyKey, out string[] enumerableProps) |
||||
|
{ |
||||
|
if (definition.Properties.TryGetValue(propertyKey, out var propertyKeyValues) && propertyKeyValues != null) |
||||
|
{ |
||||
|
enumerableProps = propertyKeyValues.ToString()!.Split(','); |
||||
|
return true; |
||||
|
} |
||||
|
enumerableProps = []; |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
private static SettingResourceDefinition? GetResourceOrNull(SettingDefinition definition, string resourceKey) |
||||
|
{ |
||||
|
if (definition.Properties.TryGetValue(resourceKey, out var resource) && resource != null) |
||||
|
{ |
||||
|
var resourceDefineStr = resource.ToString(); |
||||
|
if (string.IsNullOrWhiteSpace(resourceDefineStr)) |
||||
|
{ |
||||
|
return null; |
||||
|
} |
||||
|
var resourceDefineKeys = resourceDefineStr.Split(','); |
||||
|
if (resourceDefineKeys.Length < 6) |
||||
|
{ |
||||
|
return null; |
||||
|
} |
||||
|
var name = resourceDefineKeys[0].Substring(2); |
||||
|
var displayName = resourceDefineKeys[1].Substring(2); |
||||
|
var resourceName = resourceDefineKeys[2]; |
||||
|
SettingResourceDefinition settingResource; |
||||
|
if (resourceName.Length > 2) |
||||
|
{ |
||||
|
settingResource = new SettingResourceDefinition( |
||||
|
name, |
||||
|
new LocalizableString( |
||||
|
displayName, |
||||
|
resourceName.Substring(2))); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
settingResource = new SettingResourceDefinition( |
||||
|
name, |
||||
|
new FixedLocalizableString(displayName)); |
||||
|
} |
||||
|
if (resourceDefineKeys[4].Length > 2) |
||||
|
{ |
||||
|
settingResource.RequiredFeatures = resourceDefineKeys[4].Substring(2).Split(';'); |
||||
|
} |
||||
|
if (resourceDefineKeys[5].Length > 2) |
||||
|
{ |
||||
|
settingResource.RequiredPermissions = resourceDefineKeys[5].Substring(2).Split(';'); |
||||
|
} |
||||
|
if (resourceDefineKeys[6].Length > 2 && int.TryParse(resourceDefineKeys[6].Substring(2), out var order)) |
||||
|
{ |
||||
|
settingResource.Order = order; |
||||
|
} |
||||
|
|
||||
|
return settingResource; |
||||
|
} |
||||
|
|
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,119 @@ |
|||||
|
using Microsoft.Extensions.Localization; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using Volo.Abp.Localization; |
||||
|
|
||||
|
namespace Volo.Abp.Settings; |
||||
|
|
||||
|
public class SettingResourceDefinition |
||||
|
{ |
||||
|
public int Order { get; set; } |
||||
|
public string Name { get; set; } |
||||
|
public string? DisplayName { get; set; } |
||||
|
public string? ResourceName { get; set; } |
||||
|
public string? ResourceType { get; set; } |
||||
|
public string[]? RequiredFeatures { get; set; } |
||||
|
public string[]? RequiredPermissions { get; set; } |
||||
|
|
||||
|
public SettingResourceDefinition( |
||||
|
string name, |
||||
|
FixedLocalizableString displayName, |
||||
|
int order = 0, |
||||
|
string[]? requiredFeatures = null, |
||||
|
string[]? requiredPermissions = null) |
||||
|
{ |
||||
|
Name = name; |
||||
|
Order = order; |
||||
|
DisplayName = displayName.Value; |
||||
|
RequiredFeatures = requiredFeatures; |
||||
|
RequiredPermissions = requiredPermissions; |
||||
|
} |
||||
|
|
||||
|
public SettingResourceDefinition( |
||||
|
string name, |
||||
|
LocalizableString displayName, |
||||
|
int order = 0, |
||||
|
string[]? requiredFeatures = null, |
||||
|
string[]? requiredPermissions = null) |
||||
|
{ |
||||
|
Name = name; |
||||
|
Order = order; |
||||
|
ResourceName = displayName.ResourceName; |
||||
|
ResourceType = displayName.ResourceType?.FullName; |
||||
|
DisplayName = displayName.Name; |
||||
|
RequiredFeatures = requiredFeatures; |
||||
|
RequiredPermissions = requiredPermissions; |
||||
|
} |
||||
|
|
||||
|
public LocalizedString Localize(IStringLocalizerFactory stringLocalizerFactory) |
||||
|
{ |
||||
|
if (!string.IsNullOrWhiteSpace(ResourceName) && |
||||
|
!string.IsNullOrWhiteSpace(DisplayName)) |
||||
|
{ |
||||
|
if (!string.IsNullOrWhiteSpace(ResourceType)) |
||||
|
{ |
||||
|
return new LocalizableString(DisplayName!, ResourceType).Localize(stringLocalizerFactory); |
||||
|
} |
||||
|
return new LocalizableString(DisplayName!, ResourceName).Localize(stringLocalizerFactory); |
||||
|
} |
||||
|
else if (!string.IsNullOrWhiteSpace(DisplayName)) |
||||
|
{ |
||||
|
return new LocalizedString(Name!, DisplayName!); |
||||
|
} |
||||
|
return new LocalizedString(Name, Name); |
||||
|
} |
||||
|
|
||||
|
public override string ToString() |
||||
|
{ |
||||
|
var sb = new StringBuilder(); |
||||
|
sb.AppendFormat("N:{0}", Name); |
||||
|
sb.AppendFormat(",D:{0}", DisplayName ?? string.Empty); |
||||
|
sb.AppendFormat(",L:{0}", ResourceName ?? string.Empty); |
||||
|
sb.AppendFormat(",T:{0}", ResourceType ?? string.Empty); |
||||
|
sb.AppendFormat(",F:{0}", RequiredFeatures?.JoinAsString(";") ?? string.Empty); |
||||
|
sb.AppendFormat(",P:{0}", RequiredPermissions?.JoinAsString(";") ?? string.Empty); |
||||
|
sb.AppendFormat(",O:{0}", Order); |
||||
|
|
||||
|
return sb.ToString(); |
||||
|
} |
||||
|
|
||||
|
public override bool Equals(object? obj) |
||||
|
{ |
||||
|
if (obj == null) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
if (obj is SettingResourceDefinition other) |
||||
|
{ |
||||
|
return string.Equals(Name, other.Name, StringComparison.CurrentCultureIgnoreCase); |
||||
|
} |
||||
|
|
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
public override int GetHashCode() |
||||
|
{ |
||||
|
return StringComparer.CurrentCultureIgnoreCase.GetHashCode(Name); |
||||
|
} |
||||
|
|
||||
|
public static bool operator ==(SettingResourceDefinition? left, SettingResourceDefinition? right) |
||||
|
{ |
||||
|
if (ReferenceEquals(left, right)) |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
if (left is null || right is null) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
return left.Equals(right); |
||||
|
} |
||||
|
|
||||
|
public static bool operator !=(SettingResourceDefinition? left, SettingResourceDefinition? right) |
||||
|
{ |
||||
|
return !(left == right); |
||||
|
} |
||||
|
} |
||||
@ -1,4 +1,4 @@ |
|||||
namespace LINGYUN.Abp.SettingManagement; |
namespace Volo.Abp.Settings; |
||||
|
|
||||
public enum ValueType |
public enum ValueType |
||||
{ |
{ |
||||
@ -0,0 +1,31 @@ |
|||||
|
using Volo.Abp.Account.Localization; |
||||
|
using Volo.Abp.Account.Settings; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.Settings; |
||||
|
using ValueType = Volo.Abp.Settings.ValueType; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Account; |
||||
|
|
||||
|
public class AccountGroupSettingDefinitionProvider : SettingDefinitionProvider |
||||
|
{ |
||||
|
private const string GroupName = "Identity"; |
||||
|
private const int GroupOrder = 10; |
||||
|
public override void Define(ISettingDefinitionContext context) |
||||
|
{ |
||||
|
context.GetOrNull(AccountSettingNames.EnableLocalLogin) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("Account", L("Settings:Identity.Account"), order: 0) |
||||
|
?.WithOrder(0) |
||||
|
?.WithValueType(ValueType.Boolean); |
||||
|
context.GetOrNull(AccountSettingNames.IsSelfRegistrationEnabled) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("Account", L("Settings:Identity.Account"), order: 0) |
||||
|
?.WithOrder(1) |
||||
|
?.WithValueType(ValueType.Boolean); |
||||
|
} |
||||
|
|
||||
|
private static LocalizableString L(string name) |
||||
|
{ |
||||
|
return LocalizableString.Create<AccountResource>(name); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,18 @@ |
|||||
|
using LINGYUN.Abp.BlobManagement.Permissions; |
||||
|
using LINGYUN.Abp.BlobManagement.Settings; |
||||
|
using Volo.Abp.Settings; |
||||
|
|
||||
|
namespace LINGYUN.Abp.BlobManagement; |
||||
|
|
||||
|
public class BlobManagementPermissionSettingDefinitionProvider : SettingDefinitionProvider |
||||
|
{ |
||||
|
public override void Define(ISettingDefinitionContext context) |
||||
|
{ |
||||
|
context.GetOrNull(BlobManagementSettingNames.GenerateDownloadUrlExpirySeconds) |
||||
|
?.RequiredGroupPermissions([BlobManagementPermissionNames.Blob.Default]); |
||||
|
context.GetOrNull(BlobManagementSettingNames.FileLimitLength) |
||||
|
?.RequiredGroupPermissions([BlobManagementPermissionNames.Blob.Default]); |
||||
|
context.GetOrNull(BlobManagementSettingNames.AllowFileExtensions) |
||||
|
?.RequiredGroupPermissions([BlobManagementPermissionNames.Blob.Default]); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,247 @@ |
|||||
|
using Volo.Abp.Identity.Localization; |
||||
|
using Volo.Abp.Identity.Settings; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.Settings; |
||||
|
using ValueType = Volo.Abp.Settings.ValueType; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Identity; |
||||
|
|
||||
|
public class IdentityGroupSettingDefinitionProvider : SettingDefinitionProvider |
||||
|
{ |
||||
|
private const string GroupName = "Identity"; |
||||
|
private const int GroupOrder = 10; |
||||
|
|
||||
|
public override void Define(ISettingDefinitionContext context) |
||||
|
{ |
||||
|
SetLockoutSettingGroup(context); |
||||
|
SetUserSettingGroup(context); |
||||
|
SetSignInSettingGroup(context); |
||||
|
SetPasswordSettingGroup(context); |
||||
|
SetOrganizationUnitSettingGroup(context); |
||||
|
} |
||||
|
|
||||
|
private static void SetLockoutSettingGroup(ISettingDefinitionContext context) |
||||
|
{ |
||||
|
context.GetOrNull(IdentitySettingNames.Lockout.AllowedForNewUsers) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("Lockout", L("Settings:Identity.Lockout"), order: 3) |
||||
|
?.WithOrder(0) |
||||
|
?.WithValueType(ValueType.Boolean) |
||||
|
?.ReplaceProviders( |
||||
|
DefaultValueSettingValueProvider.ProviderName, |
||||
|
ConfigurationSettingValueProvider.ProviderName, |
||||
|
GlobalSettingValueProvider.ProviderName, |
||||
|
TenantSettingValueProvider.ProviderName); |
||||
|
context.GetOrNull(IdentitySettingNames.Lockout.LockoutDuration) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("Lockout", L("Settings:Identity.Lockout"), order: 3) |
||||
|
?.WithOrder(1) |
||||
|
?.WithValueType(ValueType.Number) |
||||
|
?.ReplaceProviders( |
||||
|
DefaultValueSettingValueProvider.ProviderName, |
||||
|
ConfigurationSettingValueProvider.ProviderName, |
||||
|
GlobalSettingValueProvider.ProviderName, |
||||
|
TenantSettingValueProvider.ProviderName); |
||||
|
context.GetOrNull(IdentitySettingNames.Lockout.MaxFailedAccessAttempts) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("Lockout", L("Settings:Identity.Lockout"), order: 3) |
||||
|
?.WithOrder(2) |
||||
|
?.WithValueType(ValueType.Number) |
||||
|
?.ReplaceProviders( |
||||
|
DefaultValueSettingValueProvider.ProviderName, |
||||
|
ConfigurationSettingValueProvider.ProviderName, |
||||
|
GlobalSettingValueProvider.ProviderName, |
||||
|
TenantSettingValueProvider.ProviderName); |
||||
|
} |
||||
|
|
||||
|
private static void SetUserSettingGroup(ISettingDefinitionContext context) |
||||
|
{ |
||||
|
context.GetOrNull(IdentitySettingNames.User.IsEmailUpdateEnabled) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("User", L("Settings:Identity.User"), order: 1) |
||||
|
?.WithOrder(0) |
||||
|
?.WithValueType(ValueType.Boolean) |
||||
|
?.ReplaceProviders( |
||||
|
DefaultValueSettingValueProvider.ProviderName, |
||||
|
ConfigurationSettingValueProvider.ProviderName, |
||||
|
GlobalSettingValueProvider.ProviderName, |
||||
|
TenantSettingValueProvider.ProviderName); |
||||
|
context.GetOrNull(IdentitySettingNames.User.IsUserNameUpdateEnabled) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("User", L("Settings:Identity.User"), order: 1) |
||||
|
?.WithOrder(1) |
||||
|
?.WithValueType(ValueType.Boolean) |
||||
|
?.ReplaceProviders( |
||||
|
DefaultValueSettingValueProvider.ProviderName, |
||||
|
ConfigurationSettingValueProvider.ProviderName, |
||||
|
GlobalSettingValueProvider.ProviderName, |
||||
|
TenantSettingValueProvider.ProviderName); |
||||
|
} |
||||
|
|
||||
|
private static void SetSignInSettingGroup(ISettingDefinitionContext context) |
||||
|
{ |
||||
|
context.GetOrNull(IdentitySettingNames.SignIn.RequireConfirmedEmail) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("SignIn", L("Settings:Identity.SignIn"), order: 2) |
||||
|
?.WithOrder(0) |
||||
|
?.WithValueType(ValueType.Boolean) |
||||
|
?.ReplaceProviders( |
||||
|
DefaultValueSettingValueProvider.ProviderName, |
||||
|
ConfigurationSettingValueProvider.ProviderName, |
||||
|
GlobalSettingValueProvider.ProviderName, |
||||
|
TenantSettingValueProvider.ProviderName); |
||||
|
context.GetOrNull(IdentitySettingNames.SignIn.RequireEmailVerificationToRegister) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("SignIn", L("Settings:Identity.SignIn"), order: 2) |
||||
|
?.WithOrder(1) |
||||
|
?.WithValueType(ValueType.Boolean) |
||||
|
?.ReplaceProviders( |
||||
|
DefaultValueSettingValueProvider.ProviderName, |
||||
|
ConfigurationSettingValueProvider.ProviderName, |
||||
|
GlobalSettingValueProvider.ProviderName, |
||||
|
TenantSettingValueProvider.ProviderName); |
||||
|
context.GetOrNull(IdentitySettingNames.SignIn.EnablePhoneNumberConfirmation) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("SignIn", L("Settings:Identity.SignIn"), order: 2) |
||||
|
?.WithOrder(2) |
||||
|
?.WithValueType(ValueType.Boolean) |
||||
|
?.ReplaceProviders( |
||||
|
DefaultValueSettingValueProvider.ProviderName, |
||||
|
ConfigurationSettingValueProvider.ProviderName, |
||||
|
GlobalSettingValueProvider.ProviderName, |
||||
|
TenantSettingValueProvider.ProviderName); |
||||
|
context.GetOrNull(IdentitySettingNames.SignIn.RequireConfirmedPhoneNumber) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("SignIn", L("Settings:Identity.SignIn"), order: 2) |
||||
|
?.WithOrder(3) |
||||
|
?.WithValueType(ValueType.Boolean) |
||||
|
?.ReplaceProviders( |
||||
|
DefaultValueSettingValueProvider.ProviderName, |
||||
|
ConfigurationSettingValueProvider.ProviderName, |
||||
|
GlobalSettingValueProvider.ProviderName, |
||||
|
TenantSettingValueProvider.ProviderName); |
||||
|
} |
||||
|
|
||||
|
private static void SetPasswordSettingGroup(ISettingDefinitionContext context) |
||||
|
{ |
||||
|
context.GetOrNull(IdentitySettingNames.Password.RequireDigit) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("Password", L("Settings:Identity.Password"), order: 4) |
||||
|
?.WithOrder(0) |
||||
|
?.WithValueType(ValueType.Boolean) |
||||
|
?.ReplaceProviders( |
||||
|
DefaultValueSettingValueProvider.ProviderName, |
||||
|
ConfigurationSettingValueProvider.ProviderName, |
||||
|
GlobalSettingValueProvider.ProviderName, |
||||
|
TenantSettingValueProvider.ProviderName); |
||||
|
context.GetOrNull(IdentitySettingNames.Password.RequiredLength) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("Password", L("Settings:Identity.Password"), order: 4) |
||||
|
?.WithOrder(1) |
||||
|
?.WithValueType(ValueType.Number) |
||||
|
?.ReplaceProviders( |
||||
|
DefaultValueSettingValueProvider.ProviderName, |
||||
|
ConfigurationSettingValueProvider.ProviderName, |
||||
|
GlobalSettingValueProvider.ProviderName, |
||||
|
TenantSettingValueProvider.ProviderName); |
||||
|
context.GetOrNull(IdentitySettingNames.Password.RequiredUniqueChars) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("Password", L("Settings:Identity.Password"), order: 4) |
||||
|
?.WithOrder(2) |
||||
|
?.WithValueType(ValueType.Number) |
||||
|
?.ReplaceProviders( |
||||
|
DefaultValueSettingValueProvider.ProviderName, |
||||
|
ConfigurationSettingValueProvider.ProviderName, |
||||
|
GlobalSettingValueProvider.ProviderName, |
||||
|
TenantSettingValueProvider.ProviderName); |
||||
|
context.GetOrNull(IdentitySettingNames.Password.RequireLowercase) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("Password", L("Settings:Identity.Password"), order: 4) |
||||
|
?.WithOrder(3) |
||||
|
?.WithValueType(ValueType.Boolean) |
||||
|
?.ReplaceProviders( |
||||
|
DefaultValueSettingValueProvider.ProviderName, |
||||
|
ConfigurationSettingValueProvider.ProviderName, |
||||
|
GlobalSettingValueProvider.ProviderName, |
||||
|
TenantSettingValueProvider.ProviderName); |
||||
|
context.GetOrNull(IdentitySettingNames.Password.RequireUppercase) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("Password", L("Settings:Identity.Password"), order: 4) |
||||
|
?.WithOrder(4) |
||||
|
?.WithValueType(ValueType.Boolean) |
||||
|
?.ReplaceProviders( |
||||
|
DefaultValueSettingValueProvider.ProviderName, |
||||
|
ConfigurationSettingValueProvider.ProviderName, |
||||
|
GlobalSettingValueProvider.ProviderName, |
||||
|
TenantSettingValueProvider.ProviderName); |
||||
|
context.GetOrNull(IdentitySettingNames.Password.RequireNonAlphanumeric) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("Password", L("Settings:Identity.Password"), order: 4) |
||||
|
?.WithOrder(5) |
||||
|
?.WithValueType(ValueType.Boolean) |
||||
|
?.ReplaceProviders( |
||||
|
DefaultValueSettingValueProvider.ProviderName, |
||||
|
ConfigurationSettingValueProvider.ProviderName, |
||||
|
GlobalSettingValueProvider.ProviderName, |
||||
|
TenantSettingValueProvider.ProviderName); |
||||
|
context.GetOrNull(IdentitySettingNames.Password.ForceUsersToPeriodicallyChangePassword) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("Password", L("Settings:Identity.Password"), order: 4) |
||||
|
?.WithOrder(6) |
||||
|
?.WithValueType(ValueType.Boolean) |
||||
|
?.ReplaceProviders( |
||||
|
DefaultValueSettingValueProvider.ProviderName, |
||||
|
ConfigurationSettingValueProvider.ProviderName, |
||||
|
GlobalSettingValueProvider.ProviderName, |
||||
|
TenantSettingValueProvider.ProviderName); |
||||
|
context.GetOrNull(IdentitySettingNames.Password.PasswordChangePeriodDays) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("Password", L("Settings:Identity.Password"), order: 4) |
||||
|
?.WithOrder(7) |
||||
|
?.WithValueType(ValueType.Number) |
||||
|
?.ReplaceProviders( |
||||
|
DefaultValueSettingValueProvider.ProviderName, |
||||
|
ConfigurationSettingValueProvider.ProviderName, |
||||
|
GlobalSettingValueProvider.ProviderName, |
||||
|
TenantSettingValueProvider.ProviderName); |
||||
|
context.GetOrNull(IdentitySettingNames.Password.EnablePreventPasswordReuse) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("Password", L("Settings:Identity.Password"), order: 4) |
||||
|
?.WithOrder(8) |
||||
|
?.WithValueType(ValueType.Boolean) |
||||
|
?.ReplaceProviders( |
||||
|
DefaultValueSettingValueProvider.ProviderName, |
||||
|
ConfigurationSettingValueProvider.ProviderName, |
||||
|
GlobalSettingValueProvider.ProviderName, |
||||
|
TenantSettingValueProvider.ProviderName); |
||||
|
context.GetOrNull(IdentitySettingNames.Password.PreventPasswordReuseCount) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("Password", L("Settings:Identity.Password"), order: 4) |
||||
|
?.WithOrder(9) |
||||
|
?.WithValueType(ValueType.Number) |
||||
|
?.ReplaceProviders( |
||||
|
DefaultValueSettingValueProvider.ProviderName, |
||||
|
ConfigurationSettingValueProvider.ProviderName, |
||||
|
GlobalSettingValueProvider.ProviderName, |
||||
|
TenantSettingValueProvider.ProviderName); |
||||
|
} |
||||
|
|
||||
|
private static void SetOrganizationUnitSettingGroup(ISettingDefinitionContext context) |
||||
|
{ |
||||
|
context.GetOrNull(IdentitySettingNames.OrganizationUnit.MaxUserMembershipCount) |
||||
|
?.WithGroup(GroupName, L("Settings:Identity"), GroupOrder) |
||||
|
?.WithParent("OrganizationUnit", L("Settings:Identity.OrganizationUnit"), order: 6) |
||||
|
?.WithOrder(0) |
||||
|
?.WithValueType(ValueType.Number) |
||||
|
?.ReplaceProviders( |
||||
|
DefaultValueSettingValueProvider.ProviderName, |
||||
|
ConfigurationSettingValueProvider.ProviderName, |
||||
|
GlobalSettingValueProvider.ProviderName, |
||||
|
TenantSettingValueProvider.ProviderName); |
||||
|
} |
||||
|
|
||||
|
private static LocalizableString L(string name) |
||||
|
{ |
||||
|
return LocalizableString.Create<IdentityResource>(name); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,62 @@ |
|||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; |
||||
|
using Volo.Abp.EventBus.Distributed; |
||||
|
using Volo.Abp.Features; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
using Volo.Abp.SettingManagement; |
||||
|
using Volo.Abp.Settings; |
||||
|
|
||||
|
namespace LINGYUN.Abp.SettingManagement; |
||||
|
|
||||
|
[Authorize(AbpSettingManagementPermissions.Settings.Default)] |
||||
|
public class SettingV2AppService : SettingV2AppServiceBase, ISettingV2AppService |
||||
|
{ |
||||
|
public SettingV2AppService( |
||||
|
IDistributedEventBus eventBus, |
||||
|
ISettingManager settingManager, |
||||
|
ISettingDefinitionManager settingDefinitionManager) |
||||
|
: base(eventBus, settingManager, settingDefinitionManager) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public async virtual Task<SettingGroupResult> GetAsync() |
||||
|
{ |
||||
|
await CheckFeatureAsync(); |
||||
|
|
||||
|
var providerName = CurrentTenant.GetMultiTenancySide() == MultiTenancySides.Host |
||||
|
? GlobalSettingValueProvider.ProviderName |
||||
|
: TenantSettingValueProvider.ProviderName; |
||||
|
var providerKey = CurrentTenant.GetMultiTenancySide() == MultiTenancySides.Host |
||||
|
? null |
||||
|
: CurrentTenant.GetId().ToString(); |
||||
|
|
||||
|
return await GetAllForProviderAsync(providerName, providerKey); |
||||
|
} |
||||
|
|
||||
|
[Authorize(AbpSettingManagementPermissions.Settings.Manager)] |
||||
|
public async virtual Task SetAsync(UpdateSettingsDto input) |
||||
|
{ |
||||
|
await CheckFeatureAsync(); |
||||
|
|
||||
|
var multiTenancySides = CurrentTenant.GetMultiTenancySide(); |
||||
|
foreach (var setting in input.Settings) |
||||
|
{ |
||||
|
if (multiTenancySides == MultiTenancySides.Host) |
||||
|
{ |
||||
|
await SettingManager.SetGlobalAsync(setting.Name, setting.Value); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
await SettingManager.SetForTenantAsync(CurrentTenant.GetId(), setting.Name, setting.Value); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
CurrentUnitOfWork.OnCompleted(async () => |
||||
|
{ |
||||
|
await EventBus.PublishAsync(new CurrentApplicationConfigurationCacheResetEventData()); |
||||
|
}); |
||||
|
|
||||
|
await CurrentUnitOfWork.SaveChangesAsync(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,165 @@ |
|||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using System; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
using Volo.Abp.EventBus.Distributed; |
||||
|
using Volo.Abp.Features; |
||||
|
using Volo.Abp.SettingManagement; |
||||
|
using Volo.Abp.SettingManagement.Localization; |
||||
|
using Volo.Abp.Settings; |
||||
|
using ValueType = Volo.Abp.Settings.ValueType; |
||||
|
|
||||
|
namespace LINGYUN.Abp.SettingManagement; |
||||
|
|
||||
|
public abstract class SettingV2AppServiceBase : ApplicationService |
||||
|
{ |
||||
|
protected IDistributedEventBus EventBus { get; } |
||||
|
protected ISettingManager SettingManager { get; } |
||||
|
protected ISettingDefinitionManager SettingDefinitionManager { get; } |
||||
|
|
||||
|
protected SettingV2AppServiceBase( |
||||
|
IDistributedEventBus eventBus, |
||||
|
ISettingManager settingManager, |
||||
|
ISettingDefinitionManager settingDefinitionManager) |
||||
|
{ |
||||
|
EventBus = eventBus; |
||||
|
SettingManager = settingManager; |
||||
|
SettingDefinitionManager = settingDefinitionManager; |
||||
|
|
||||
|
LocalizationResource = typeof(AbpSettingManagementResource); |
||||
|
} |
||||
|
|
||||
|
protected async virtual Task<SettingGroupResult> GetAllForProviderAsync(string providerName, string providerKey) |
||||
|
{ |
||||
|
var result = new SettingGroupResult(); |
||||
|
|
||||
|
var settingDefines = await SettingDefinitionManager.GetAllAsync(); |
||||
|
|
||||
|
|
||||
|
SettingGroupDto CreateSettingGroup(SettingResourceDefinition resource) |
||||
|
{ |
||||
|
return resource != null |
||||
|
? new SettingGroupDto(resource.Localize(StringLocalizerFactory).Value) |
||||
|
: new SettingGroupDto(L["Settings:DefaultGroup"]); |
||||
|
} |
||||
|
SettingDto CreateSetting(SettingGroupDto groupDto, SettingResourceDefinition resource) |
||||
|
{ |
||||
|
var settingDisplayName = resource != null |
||||
|
? resource.Localize(StringLocalizerFactory).Value |
||||
|
: L["Settings:DefaultSetting"]; |
||||
|
return groupDto.AddSetting(settingDisplayName, settingDisplayName); |
||||
|
} |
||||
|
async Task<bool> IsEnabledSettingResource(SettingResourceDefinition resource) |
||||
|
{ |
||||
|
if (resource?.RequiredFeatures != null) |
||||
|
{ |
||||
|
var checkFeatures = await FeatureChecker.IsEnabledAsync(resource.RequiredFeatures); |
||||
|
if (!checkFeatures.Any(x => x.Value)) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
if (resource?.RequiredPermissions != null && |
||||
|
!await AuthorizationService.IsGrantedAnyAsync(resource.RequiredPermissions)) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
return true; |
||||
|
} |
||||
|
async Task<bool> IsEnabledSetting(SettingDefinition setting) |
||||
|
{ |
||||
|
if (setting.Providers.Count > 0 && !setting.Providers.Any(provider => provider == providerName)) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
var requiredFeatures = setting.GetRequiredFeatures(); |
||||
|
if (requiredFeatures.Any()) |
||||
|
{ |
||||
|
var checkFeatures = await FeatureChecker.IsEnabledAsync(requiredFeatures.ToArray()); |
||||
|
if (!checkFeatures.Any(x => x.Value)) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
var requiredPermissions = setting.GetRequiredPermissions(); |
||||
|
if (requiredPermissions.Any() && |
||||
|
!await AuthorizationService.IsGrantedAnyAsync(requiredPermissions.ToArray())) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
foreach (var settingGroups in settingDefines.GroupBy(x => x.GetGroupOrNull()).OrderBy(x => x.Key?.Order ?? 9999)) |
||||
|
{ |
||||
|
if (!await IsEnabledSettingResource(settingGroups.Key)) |
||||
|
{ |
||||
|
continue; |
||||
|
} |
||||
|
var groupDto = CreateSettingGroup(settingGroups.Key); |
||||
|
foreach (var settings in settingGroups.GroupBy(x => x.GetParentOrNull()).OrderBy(x => x.Key?.Order ?? 9999)) |
||||
|
{ |
||||
|
if (!await IsEnabledSettingResource(settings.Key)) |
||||
|
{ |
||||
|
continue; |
||||
|
} |
||||
|
var settingDto = CreateSetting(groupDto, settings.Key); |
||||
|
|
||||
|
foreach (var setting in settings) |
||||
|
{ |
||||
|
if (!await IsEnabledSetting(setting)) |
||||
|
{ |
||||
|
continue; |
||||
|
} |
||||
|
var valueType = setting.GetValueTypeOrDefault(); |
||||
|
|
||||
|
var settingDetailsDto = settingDto.AddDetail( |
||||
|
await SettingDefinitionManager.GetAsync(setting.Name), |
||||
|
StringLocalizerFactory, |
||||
|
await SettingManager.GetOrNullAsync(setting.Name, providerName, providerKey), |
||||
|
valueType, |
||||
|
providerName); |
||||
|
|
||||
|
if (valueType == ValueType.Option) |
||||
|
{ |
||||
|
var options = setting.GetOptions(); |
||||
|
settingDetailsDto.AddOptions(options.Select(option => new OptionDto(option.Name, option.Value))); |
||||
|
} |
||||
|
|
||||
|
var slot = setting.GetSlotOrNull(); |
||||
|
if (!slot.IsNullOrWhiteSpace()) |
||||
|
{ |
||||
|
settingDetailsDto.WithSlot(slot); |
||||
|
} |
||||
|
|
||||
|
var requiredFeatures = setting.GetRequiredFeatures(); |
||||
|
if (requiredFeatures.Any()) |
||||
|
{ |
||||
|
settingDetailsDto.RequiredFeature(requiredFeatures.ToArray()); |
||||
|
} |
||||
|
|
||||
|
var requiredPermissions = setting.GetRequiredPermissions(); |
||||
|
if (requiredPermissions.Any()) |
||||
|
{ |
||||
|
settingDetailsDto.RequiredPermission(requiredPermissions.ToArray()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (settingDto.Details.Count == 0) |
||||
|
{ |
||||
|
groupDto.Settings.Remove(settingDto); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
result.AddGroup(groupDto); |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
protected async virtual Task CheckFeatureAsync() |
||||
|
{ |
||||
|
await FeatureChecker.CheckEnabledAsync(SettingManagementFeatures.Enable); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,38 @@ |
|||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.EventBus.Distributed; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
using Volo.Abp.SettingManagement; |
||||
|
using Volo.Abp.Settings; |
||||
|
using Volo.Abp.Users; |
||||
|
|
||||
|
namespace LINGYUN.Abp.SettingManagement; |
||||
|
|
||||
|
[Authorize] |
||||
|
public class UserSettingV2AppService : SettingV2AppServiceBase, IUserSettingV2AppService |
||||
|
{ |
||||
|
public UserSettingV2AppService( |
||||
|
IDistributedEventBus eventBus, |
||||
|
ISettingManager settingManager, |
||||
|
ISettingDefinitionManager settingDefinitionManager) |
||||
|
: base(eventBus, settingManager, settingDefinitionManager) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public async virtual Task<SettingGroupResult> GetAsync() |
||||
|
{ |
||||
|
await CheckFeatureAsync(); |
||||
|
|
||||
|
return await GetAllForProviderAsync(UserSettingValueProvider.ProviderName, CurrentUser.GetId().ToString()); |
||||
|
} |
||||
|
|
||||
|
public async virtual Task SetAsync(UpdateSettingsDto input) |
||||
|
{ |
||||
|
await CheckFeatureAsync(); |
||||
|
|
||||
|
foreach (var setting in input.Settings) |
||||
|
{ |
||||
|
await SettingManager.SetForCurrentUserAsync(setting.Name, setting.Value); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,59 +1,59 @@ |
|||||
using Microsoft.AspNetCore.Authorization; |
using Microsoft.AspNetCore.Authorization; |
||||
using Microsoft.AspNetCore.Mvc; |
using Microsoft.AspNetCore.Mvc; |
||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
using Volo.Abp; |
using Volo.Abp; |
||||
using Volo.Abp.AspNetCore.Mvc; |
using Volo.Abp.AspNetCore.Mvc; |
||||
|
|
||||
namespace LINGYUN.Abp.SettingManagement; |
namespace LINGYUN.Abp.SettingManagement; |
||||
|
|
||||
[RemoteService(Name = AbpSettingManagementRemoteServiceConsts.RemoteServiceName)] |
[RemoteService(Name = AbpSettingManagementRemoteServiceConsts.RemoteServiceName)] |
||||
[Area("SettingManagement")] |
[Area("SettingManagement")] |
||||
[Route("api/setting-management/settings")] |
[Route("api/setting-management/settings")] |
||||
public class SettingController : AbpControllerBase, ISettingAppService, ISettingTestAppService |
public class SettingController : AbpControllerBase, ISettingAppService, ISettingTestAppService |
||||
{ |
{ |
||||
private readonly ISettingAppService _settingAppService; |
private readonly ISettingAppService _settingAppService; |
||||
private readonly ISettingTestAppService _settingTestAppService; |
private readonly ISettingTestAppService _settingTestAppService; |
||||
public SettingController( |
public SettingController( |
||||
ISettingAppService settingAppService, |
ISettingAppService settingAppService, |
||||
ISettingTestAppService settingTestAppService) |
ISettingTestAppService settingTestAppService) |
||||
{ |
{ |
||||
_settingAppService = settingAppService; |
_settingAppService = settingAppService; |
||||
_settingTestAppService = settingTestAppService; |
_settingTestAppService = settingTestAppService; |
||||
} |
} |
||||
|
|
||||
[HttpPut] |
[HttpPut] |
||||
[Route("change-current-tenant")] |
[Route("change-current-tenant")] |
||||
public async virtual Task SetCurrentTenantAsync(UpdateSettingsDto input) |
public async virtual Task SetCurrentTenantAsync(UpdateSettingsDto input) |
||||
{ |
{ |
||||
await _settingAppService.SetCurrentTenantAsync(input); |
await _settingAppService.SetCurrentTenantAsync(input); |
||||
} |
} |
||||
|
|
||||
[HttpPut] |
[HttpPut] |
||||
[Route("change-global")] |
[Route("change-global")] |
||||
public async virtual Task SetGlobalAsync(UpdateSettingsDto input) |
public async virtual Task SetGlobalAsync(UpdateSettingsDto input) |
||||
{ |
{ |
||||
await _settingAppService.SetGlobalAsync(input); |
await _settingAppService.SetGlobalAsync(input); |
||||
} |
} |
||||
|
|
||||
[HttpGet] |
[HttpGet] |
||||
[Route("by-global")] |
[Route("by-global")] |
||||
public async virtual Task<SettingGroupResult> GetAllForGlobalAsync() |
public async virtual Task<SettingGroupResult> GetAllForGlobalAsync() |
||||
{ |
{ |
||||
return await _settingAppService.GetAllForGlobalAsync(); |
return await _settingAppService.GetAllForGlobalAsync(); |
||||
} |
} |
||||
|
|
||||
[HttpGet] |
[HttpGet] |
||||
[Route("by-current-tenant")] |
[Route("by-current-tenant")] |
||||
public async virtual Task<SettingGroupResult> GetAllForCurrentTenantAsync() |
public async virtual Task<SettingGroupResult> GetAllForCurrentTenantAsync() |
||||
{ |
{ |
||||
return await _settingAppService.GetAllForCurrentTenantAsync(); |
return await _settingAppService.GetAllForCurrentTenantAsync(); |
||||
} |
} |
||||
|
|
||||
[HttpPost] |
[HttpPost] |
||||
[Authorize] |
[Authorize] |
||||
[Route("send-test-email")] |
[Route("send-test-email")] |
||||
public async virtual Task SendTestEmailAsync(SendTestEmailInput input) |
public async virtual Task SendTestEmailAsync(SendTestEmailInput input) |
||||
{ |
{ |
||||
await _settingTestAppService.SendTestEmailAsync(input); |
await _settingTestAppService.SendTestEmailAsync(input); |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,26 @@ |
|||||
|
using Asp.Versioning; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
|
||||
|
namespace LINGYUN.Abp.SettingManagement; |
||||
|
|
||||
|
[RemoteService(Name = AbpSettingManagementRemoteServiceConsts.RemoteServiceName)] |
||||
|
[ApiVersion("2")] |
||||
|
[Area("SettingManagement")] |
||||
|
[Route("api/v{version}/setting-management/settings")] |
||||
|
public class SettingV2Controller(ISettingV2AppService _service) : AbpControllerBase, ISettingV2AppService |
||||
|
{ |
||||
|
[HttpGet] |
||||
|
public virtual Task<SettingGroupResult> GetAsync() |
||||
|
{ |
||||
|
return _service.GetAsync(); |
||||
|
} |
||||
|
|
||||
|
[HttpPut] |
||||
|
public virtual Task SetAsync(UpdateSettingsDto input) |
||||
|
{ |
||||
|
return _service.SetAsync(input); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
using Asp.Versioning; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
|
||||
|
namespace LINGYUN.Abp.SettingManagement; |
||||
|
|
||||
|
[RemoteService(Name = AbpSettingManagementRemoteServiceConsts.RemoteServiceName)] |
||||
|
[ApiVersion("2")] |
||||
|
[Area("SettingManagement")] |
||||
|
[Route("api/v{version}/setting-management/my-settings")] |
||||
|
public class UserSettingV2Controller(IUserSettingV2AppService _service) : AbpControllerBase, IUserSettingV2AppService |
||||
|
{ |
||||
|
[HttpGet] |
||||
|
public virtual Task<SettingGroupResult> GetAsync() |
||||
|
{ |
||||
|
return _service.GetAsync(); |
||||
|
} |
||||
|
|
||||
|
[HttpPut] |
||||
|
public virtual Task SetAsync(UpdateSettingsDto input) |
||||
|
{ |
||||
|
return _service.SetAsync(input); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue