From a6adb0d84174a688fd3594033fea576bef5fb1fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20=C3=87otur?= Date: Wed, 18 Mar 2020 13:06:17 +0300 Subject: [PATCH] virtualized --- .../PermissionAppService.cs | 21 ++++++++----------- .../PermissionDataSeeder.cs | 2 +- .../PermissionManagement/PermissionManager.cs | 8 +++---- .../PermissionManagement/PermissionStore.cs | 2 +- .../EfCorePermissionGrantRepository.cs | 4 ++-- .../PermissionsController.cs | 12 +++++------ .../MongoDb/MongoPermissionGrantRepository.cs | 4 ++-- .../PermissionManagementModal.cshtml.cs | 12 +++++------ .../Utils/FlatTreeDepthFinder.cs | 2 +- 9 files changed, 32 insertions(+), 35 deletions(-) diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Application/Volo/Abp/PermissionManagement/PermissionAppService.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Application/Volo/Abp/PermissionManagement/PermissionAppService.cs index 63065fd688..0c644e5d73 100644 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Application/Volo/Abp/PermissionManagement/PermissionAppService.cs +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Application/Volo/Abp/PermissionManagement/PermissionAppService.cs @@ -16,20 +16,17 @@ namespace Volo.Abp.PermissionManagement { protected PermissionManagementOptions Options { get; } - private readonly IPermissionManager _permissionManager; - private readonly IPermissionDefinitionManager _permissionDefinitionManager; - private readonly IStringLocalizerFactory _stringLocalizerFactory; + protected IPermissionManager PermissionManager { get; } + protected IPermissionDefinitionManager PermissionDefinitionManager { get; } public PermissionAppService( IPermissionManager permissionManager, IPermissionDefinitionManager permissionDefinitionManager, - IStringLocalizerFactory stringLocalizerFactory, IOptions options) { Options = options.Value; - _permissionManager = permissionManager; - _permissionDefinitionManager = permissionDefinitionManager; - _stringLocalizerFactory = stringLocalizerFactory; + PermissionManager = permissionManager; + PermissionDefinitionManager = permissionDefinitionManager; } public virtual async Task GetAsync(string providerName, string providerKey) @@ -44,12 +41,12 @@ namespace Volo.Abp.PermissionManagement var multiTenancySide = CurrentTenant.GetMultiTenancySide(); - foreach (var group in _permissionDefinitionManager.GetGroups()) + foreach (var group in PermissionDefinitionManager.GetGroups()) { var groupDto = new PermissionGroupDto { Name = group.Name, - DisplayName = group.DisplayName.Localize(_stringLocalizerFactory), + DisplayName = group.DisplayName.Localize(StringLocalizerFactory), Permissions = new List() }; @@ -68,13 +65,13 @@ namespace Volo.Abp.PermissionManagement var grantInfoDto = new PermissionGrantInfoDto { Name = permission.Name, - DisplayName = permission.DisplayName.Localize(_stringLocalizerFactory), + DisplayName = permission.DisplayName.Localize(StringLocalizerFactory), ParentName = permission.Parent?.Name, AllowedProviders = permission.Providers, GrantedProviders = new List() }; - var grantInfo = await _permissionManager.GetAsync(permission.Name, providerName, providerKey); + var grantInfo = await PermissionManager.GetAsync(permission.Name, providerName, providerKey); grantInfoDto.IsGranted = grantInfo.IsGranted; @@ -105,7 +102,7 @@ namespace Volo.Abp.PermissionManagement foreach (var permissionDto in input.Permissions) { - await _permissionManager.SetAsync(permissionDto.Name, providerName, providerKey, permissionDto.IsGranted); + await PermissionManager.SetAsync(permissionDto.Name, providerName, providerKey, permissionDto.IsGranted); } } diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionDataSeeder.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionDataSeeder.cs index 80062f528d..b01b4d740a 100644 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionDataSeeder.cs +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionDataSeeder.cs @@ -19,7 +19,7 @@ namespace Volo.Abp.PermissionManagement GuidGenerator = guidGenerator; } - public async Task SeedAsync( + public virtual async Task SeedAsync( string providerName, string providerKey, IEnumerable grantedPermissions, diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionManager.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionManager.cs index 3607a57f4b..9712c09f4b 100644 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionManager.cs +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionManager.cs @@ -50,12 +50,12 @@ namespace Volo.Abp.PermissionManagement ); } - public async Task GetAsync(string permissionName, string providerName, string providerKey) + public virtual async Task GetAsync(string permissionName, string providerName, string providerKey) { return await GetInternalAsync(PermissionDefinitionManager.Get(permissionName), providerName, providerKey); } - public async Task> GetAllAsync(string providerName, string providerKey) + public virtual async Task> GetAllAsync(string providerName, string providerKey) { var results = new List(); @@ -67,7 +67,7 @@ namespace Volo.Abp.PermissionManagement return results; } - public async Task SetAsync(string permissionName, string providerName, string providerKey, bool isGranted) + public virtual async Task SetAsync(string permissionName, string providerName, string providerKey, bool isGranted) { var permission = PermissionDefinitionManager.Get(permissionName); @@ -99,7 +99,7 @@ namespace Volo.Abp.PermissionManagement await provider.SetAsync(permissionName, providerKey, isGranted); } - public async Task UpdateProviderKeyAsync(PermissionGrant permissionGrant, string providerKey) + public virtual async Task UpdateProviderKeyAsync(PermissionGrant permissionGrant, string providerKey) { permissionGrant.ProviderKey = providerKey; return await PermissionGrantRepository.UpdateAsync(permissionGrant); diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionStore.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionStore.cs index 744dc19c8e..2ffd6f80e1 100644 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionStore.cs +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionStore.cs @@ -24,7 +24,7 @@ namespace Volo.Abp.PermissionManagement Logger = NullLogger.Instance; } - public async Task IsGrantedAsync(string name, string providerName, string providerKey) + public virtual async Task IsGrantedAsync(string name, string providerName, string providerKey) { return (await GetCacheItemAsync(name, providerName, providerKey)).IsGranted; } diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.EntityFrameworkCore/Volo/Abp/PermissionManagement/EntityFrameworkCore/EfCorePermissionGrantRepository.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.EntityFrameworkCore/Volo/Abp/PermissionManagement/EntityFrameworkCore/EfCorePermissionGrantRepository.cs index d8241d6f8f..f3536605a2 100644 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.EntityFrameworkCore/Volo/Abp/PermissionManagement/EntityFrameworkCore/EfCorePermissionGrantRepository.cs +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.EntityFrameworkCore/Volo/Abp/PermissionManagement/EntityFrameworkCore/EfCorePermissionGrantRepository.cs @@ -18,7 +18,7 @@ namespace Volo.Abp.PermissionManagement.EntityFrameworkCore } - public async Task FindAsync( + public virtual async Task FindAsync( string name, string providerName, string providerKey, @@ -33,7 +33,7 @@ namespace Volo.Abp.PermissionManagement.EntityFrameworkCore ); } - public async Task> GetListAsync( + public virtual async Task> GetListAsync( string providerName, string providerKey, CancellationToken cancellationToken = default) diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.HttpApi/Volo/Abp/PermissionManagement/PermissionsController.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.HttpApi/Volo/Abp/PermissionManagement/PermissionsController.cs index 19dcade208..2dacd79d1f 100644 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.HttpApi/Volo/Abp/PermissionManagement/PermissionsController.cs +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.HttpApi/Volo/Abp/PermissionManagement/PermissionsController.cs @@ -8,21 +8,21 @@ namespace Volo.Abp.PermissionManagement [Area("abp")] public class PermissionsController : AbpController, IPermissionAppService { - private readonly IPermissionAppService _permissionAppService; + protected IPermissionAppService PermissionAppService { get; } public PermissionsController(IPermissionAppService permissionAppService) { - _permissionAppService = permissionAppService; + PermissionAppService = permissionAppService; } - public Task GetAsync(string providerName, string providerKey) + public virtual Task GetAsync(string providerName, string providerKey) { - return _permissionAppService.GetAsync(providerName, providerKey); + return PermissionAppService.GetAsync(providerName, providerKey); } - public Task UpdateAsync(string providerName, string providerKey, UpdatePermissionsDto input) + public virtual Task UpdateAsync(string providerName, string providerKey, UpdatePermissionsDto input) { - return _permissionAppService.UpdateAsync(providerName, providerKey, input); + return PermissionAppService.UpdateAsync(providerName, providerKey, input); } } } diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.MongoDB/Volo/Abp/PermissionManagement/MongoDb/MongoPermissionGrantRepository.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.MongoDB/Volo/Abp/PermissionManagement/MongoDb/MongoPermissionGrantRepository.cs index 67befaa717..e51d9ecf7c 100644 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.MongoDB/Volo/Abp/PermissionManagement/MongoDb/MongoPermissionGrantRepository.cs +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.MongoDB/Volo/Abp/PermissionManagement/MongoDb/MongoPermissionGrantRepository.cs @@ -17,7 +17,7 @@ namespace Volo.Abp.PermissionManagement.MongoDB } - public async Task FindAsync( + public virtual async Task FindAsync( string name, string providerName, string providerKey, @@ -32,7 +32,7 @@ namespace Volo.Abp.PermissionManagement.MongoDB ); } - public async Task> GetListAsync( + public virtual async Task> GetListAsync( string providerName, string providerKey, CancellationToken cancellationToken = default) diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Pages/AbpPermissionManagement/PermissionManagementModal.cshtml.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Pages/AbpPermissionManagement/PermissionManagementModal.cshtml.cs index 70ec393455..02f5a8af17 100644 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Pages/AbpPermissionManagement/PermissionManagementModal.cshtml.cs +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Pages/AbpPermissionManagement/PermissionManagementModal.cshtml.cs @@ -29,20 +29,20 @@ namespace Volo.Abp.PermissionManagement.Web.Pages.AbpPermissionManagement public bool SelectAllInAllTabs { get; set; } - private readonly IPermissionAppService _permissionAppService; + protected IPermissionAppService PermissionAppService { get; } public PermissionManagementModal(IPermissionAppService permissionAppService) { ObjectMapperContext = typeof(AbpPermissionManagementWebModule); - _permissionAppService = permissionAppService; + PermissionAppService = permissionAppService; } - public async Task OnGetAsync() + public virtual async Task OnGetAsync() { ValidateModel(); - var result = await _permissionAppService.GetAsync(ProviderName, ProviderKey); + var result = await PermissionAppService.GetAsync(ProviderName, ProviderKey); EntityDisplayName = result.EntityDisplayName; @@ -64,7 +64,7 @@ namespace Volo.Abp.PermissionManagement.Web.Pages.AbpPermissionManagement SelectAllInAllTabs = Groups.All(g => g.IsAllPermissionsGranted); } - public async Task OnPostAsync() + public virtual async Task OnPostAsync() { ValidateModel(); @@ -77,7 +77,7 @@ namespace Volo.Abp.PermissionManagement.Web.Pages.AbpPermissionManagement }) .ToArray(); - await _permissionAppService.UpdateAsync( + await PermissionAppService.UpdateAsync( ProviderName, ProviderKey, new UpdatePermissionsDto diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Utils/FlatTreeDepthFinder.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Utils/FlatTreeDepthFinder.cs index a9e691324c..ffcd91b7da 100644 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Utils/FlatTreeDepthFinder.cs +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Utils/FlatTreeDepthFinder.cs @@ -5,7 +5,7 @@ namespace Volo.Abp.PermissionManagement.Web.Utils public class FlatTreeDepthFinder where T : class, IFlatTreeItem { - public void SetDepths(List items) + public virtual void SetDepths(List items) { SetDepths(items, null, 0); }