Improve PermissionDataSeeder

pull/9978/head
liangshiwei 4 years ago
parent 204cedc270
commit a29f3a7d4f

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
@ -32,13 +33,11 @@ namespace Volo.Abp.PermissionManagement
{
using (CurrentTenant.Change(tenantId))
{
foreach (var permissionName in grantedPermissions)
{
if (await PermissionGrantRepository.FindAsync(permissionName, providerName, providerKey) != null)
{
continue;
}
var names = grantedPermissions.ToArray();
var existsPermissionGrants = (await PermissionGrantRepository.GetListAsync(names, providerName, providerKey)).Select(x => x.Name).ToList();
foreach (var permissionName in names.Except(existsPermissionGrants))
{
await PermissionGrantRepository.InsertAsync(
new PermissionGrant(
GuidGenerator.Create(),

Loading…
Cancel
Save