virtualized

pull/3182/head
Ahmet Çotur 5 years ago
parent 55827d443d
commit a6adb0d841

@ -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<PermissionManagementOptions> options)
{
Options = options.Value;
_permissionManager = permissionManager;
_permissionDefinitionManager = permissionDefinitionManager;
_stringLocalizerFactory = stringLocalizerFactory;
PermissionManager = permissionManager;
PermissionDefinitionManager = permissionDefinitionManager;
}
public virtual async Task<GetPermissionListResultDto> 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<PermissionGrantInfoDto>()
};
@ -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<ProviderInfoDto>()
};
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);
}
}

@ -19,7 +19,7 @@ namespace Volo.Abp.PermissionManagement
GuidGenerator = guidGenerator;
}
public async Task SeedAsync(
public virtual async Task SeedAsync(
string providerName,
string providerKey,
IEnumerable<string> grantedPermissions,

@ -50,12 +50,12 @@ namespace Volo.Abp.PermissionManagement
);
}
public async Task<PermissionWithGrantedProviders> GetAsync(string permissionName, string providerName, string providerKey)
public virtual async Task<PermissionWithGrantedProviders> GetAsync(string permissionName, string providerName, string providerKey)
{
return await GetInternalAsync(PermissionDefinitionManager.Get(permissionName), providerName, providerKey);
}
public async Task<List<PermissionWithGrantedProviders>> GetAllAsync(string providerName, string providerKey)
public virtual async Task<List<PermissionWithGrantedProviders>> GetAllAsync(string providerName, string providerKey)
{
var results = new List<PermissionWithGrantedProviders>();
@ -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<PermissionGrant> UpdateProviderKeyAsync(PermissionGrant permissionGrant, string providerKey)
public virtual async Task<PermissionGrant> UpdateProviderKeyAsync(PermissionGrant permissionGrant, string providerKey)
{
permissionGrant.ProviderKey = providerKey;
return await PermissionGrantRepository.UpdateAsync(permissionGrant);

@ -24,7 +24,7 @@ namespace Volo.Abp.PermissionManagement
Logger = NullLogger<PermissionStore>.Instance;
}
public async Task<bool> IsGrantedAsync(string name, string providerName, string providerKey)
public virtual async Task<bool> IsGrantedAsync(string name, string providerName, string providerKey)
{
return (await GetCacheItemAsync(name, providerName, providerKey)).IsGranted;
}

@ -18,7 +18,7 @@ namespace Volo.Abp.PermissionManagement.EntityFrameworkCore
}
public async Task<PermissionGrant> FindAsync(
public virtual async Task<PermissionGrant> FindAsync(
string name,
string providerName,
string providerKey,
@ -33,7 +33,7 @@ namespace Volo.Abp.PermissionManagement.EntityFrameworkCore
);
}
public async Task<List<PermissionGrant>> GetListAsync(
public virtual async Task<List<PermissionGrant>> GetListAsync(
string providerName,
string providerKey,
CancellationToken cancellationToken = default)

@ -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<GetPermissionListResultDto> GetAsync(string providerName, string providerKey)
public virtual Task<GetPermissionListResultDto> 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);
}
}
}

@ -17,7 +17,7 @@ namespace Volo.Abp.PermissionManagement.MongoDB
}
public async Task<PermissionGrant> FindAsync(
public virtual async Task<PermissionGrant> FindAsync(
string name,
string providerName,
string providerKey,
@ -32,7 +32,7 @@ namespace Volo.Abp.PermissionManagement.MongoDB
);
}
public async Task<List<PermissionGrant>> GetListAsync(
public virtual async Task<List<PermissionGrant>> GetListAsync(
string providerName,
string providerKey,
CancellationToken cancellationToken = default)

@ -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<IActionResult> OnPostAsync()
public virtual async Task<IActionResult> OnPostAsync()
{
ValidateModel();
@ -77,7 +77,7 @@ namespace Volo.Abp.PermissionManagement.Web.Pages.AbpPermissionManagement
})
.ToArray();
await _permissionAppService.UpdateAsync(
await PermissionAppService.UpdateAsync(
ProviderName,
ProviderKey,
new UpdatePermissionsDto

@ -5,7 +5,7 @@ namespace Volo.Abp.PermissionManagement.Web.Utils
public class FlatTreeDepthFinder<T>
where T : class, IFlatTreeItem
{
public void SetDepths(List<T> items)
public virtual void SetDepths(List<T> items)
{
SetDepths(items, null, 0);
}

Loading…
Cancel
Save