Wizard ile eklenen Permission module eklendi
This commit is contained in:
parent
462dd20edb
commit
7ec77c551f
2 changed files with 39 additions and 21 deletions
|
|
@ -18,6 +18,7 @@ using Sozsoft.Platform.Data.Seeds;
|
|||
using Sozsoft.Platform.DynamicData;
|
||||
using Sozsoft.Platform.Entities;
|
||||
using Sozsoft.Platform.Enums;
|
||||
using Sozsoft.Platform.Extensions;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Content;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
|
|
@ -145,12 +146,17 @@ public class ListFormWizardAppService(
|
|||
// Permission'ları tek seferde kontrol et ve oluştur
|
||||
var existingPerms = await repoPerm.GetListAsync(a => a.GroupName == groupName);
|
||||
|
||||
// Yetkiler menuyle ayni modul filtresine tabidir; modul bos kalirsa rol ekraninda
|
||||
// modul secimiyle filtrelenen listede gorunmez.
|
||||
var permissionModules = input.MenuParentModuleId?.Trim();
|
||||
|
||||
var permRead = existingPerms.FirstOrDefault(a => a.Name == code);
|
||||
if (permRead == null)
|
||||
{
|
||||
permRead = await repoPerm.InsertAsync(
|
||||
new PermissionDefinitionRecord(GuidGenerator.Create(), groupName, code, null, nameLangKey, true, MultiTenancySides.Both),
|
||||
autoSave: false);
|
||||
var permReadRecord = new PermissionDefinitionRecord(GuidGenerator.Create(), groupName, code, null, nameLangKey, true, MultiTenancySides.Both);
|
||||
permReadRecord.SetModules(permissionModules);
|
||||
|
||||
permRead = await repoPerm.InsertAsync(permReadRecord, autoSave: false);
|
||||
inserted.PermissionNames.Add(permRead.Name);
|
||||
}
|
||||
|
||||
|
|
@ -186,9 +192,10 @@ public class ListFormWizardAppService(
|
|||
if (existingPerms.Any(a => a.Name == permissionName))
|
||||
continue;
|
||||
|
||||
await repoPerm.InsertAsync(
|
||||
new PermissionDefinitionRecord(GuidGenerator.Create(), groupName, permissionName, permRead.Name, langKey, true, MultiTenancySides.Both),
|
||||
autoSave: false);
|
||||
var childPermission = new PermissionDefinitionRecord(GuidGenerator.Create(), groupName, permissionName, permRead.Name, langKey, true, MultiTenancySides.Both);
|
||||
childPermission.SetModules(permissionModules);
|
||||
|
||||
await repoPerm.InsertAsync(childPermission, autoSave: false);
|
||||
inserted.PermissionNames.Add(permissionName);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ using Sozsoft.Languages.Entities;
|
|||
using Sozsoft.Languages.Languages;
|
||||
using Sozsoft.Platform.Entities;
|
||||
using Sozsoft.Platform.Enums;
|
||||
using Sozsoft.Platform.Extensions;
|
||||
using Sozsoft.Platform.ListForms;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
|
@ -208,39 +209,35 @@ public class WizardDataSeeder : IDataSeedContributor, ITransientDependency
|
|||
var permQueryable = await _repoPerm.GetQueryableAsync();
|
||||
var existingPerms = permQueryable.Where(a => a.GroupName == groupName).ToList();
|
||||
|
||||
// Yetkiler menuyle ayni modul filtresine tabidir; modul bos kalirsa rol ekraninda
|
||||
// modul secimiyle filtrelenen listede gorunmez.
|
||||
var permissionModules = input.MenuParentModuleId?.Trim();
|
||||
|
||||
var permRead = existingPerms.FirstOrDefault(a => a.Name == code);
|
||||
if (permRead == null)
|
||||
permRead = await _repoPerm.InsertAsync(new PermissionDefinitionRecord(
|
||||
Guid.NewGuid(), groupName, code, null, nameLangKey, true, MultiTenancySides.Both), autoSave: true);
|
||||
permRead ??= await InsertPermissionAsync(groupName, code, null, nameLangKey, permissionModules);
|
||||
|
||||
// CRUD üçlüsü her iki yolda da üretilir: Custom component de Form
|
||||
// üzerinden kayıt ekler, günceller ve siler (AppService.Create ile aynı davranış).
|
||||
if (!existingPerms.Any(a => a.Name == permCreateName))
|
||||
await _repoPerm.InsertAsync(new PermissionDefinitionRecord(
|
||||
Guid.NewGuid(), groupName, permCreateName, permRead.Name, WizardConsts.LangKeyCreate, true, MultiTenancySides.Both), autoSave: true);
|
||||
await InsertPermissionAsync(groupName, permCreateName, permRead.Name, WizardConsts.LangKeyCreate, permissionModules);
|
||||
|
||||
if (!existingPerms.Any(a => a.Name == permUpdateName))
|
||||
await _repoPerm.InsertAsync(new PermissionDefinitionRecord(
|
||||
Guid.NewGuid(), groupName, permUpdateName, permRead.Name, WizardConsts.LangKeyUpdate, true, MultiTenancySides.Both), autoSave: true);
|
||||
await InsertPermissionAsync(groupName, permUpdateName, permRead.Name, WizardConsts.LangKeyUpdate, permissionModules);
|
||||
|
||||
if (!existingPerms.Any(a => a.Name == permDeleteName))
|
||||
await _repoPerm.InsertAsync(new PermissionDefinitionRecord(
|
||||
Guid.NewGuid(), groupName, permDeleteName, permRead.Name, WizardConsts.LangKeyDelete, true, MultiTenancySides.Both), autoSave: true);
|
||||
await InsertPermissionAsync(groupName, permDeleteName, permRead.Name, WizardConsts.LangKeyDelete, permissionModules);
|
||||
|
||||
// Export/Import/Note yalnızca ListForm ekosisteminde karşılığı olan işlemlerdir.
|
||||
if (!isCustomComponent)
|
||||
{
|
||||
if (!existingPerms.Any(a => a.Name == permExportName))
|
||||
await _repoPerm.InsertAsync(new PermissionDefinitionRecord(
|
||||
Guid.NewGuid(), groupName, permExportName, permRead.Name, WizardConsts.LangKeyExport, true, MultiTenancySides.Both), autoSave: true);
|
||||
await InsertPermissionAsync(groupName, permExportName, permRead.Name, WizardConsts.LangKeyExport, permissionModules);
|
||||
|
||||
if (!existingPerms.Any(a => a.Name == permImportName))
|
||||
await _repoPerm.InsertAsync(new PermissionDefinitionRecord(
|
||||
Guid.NewGuid(), groupName, permImportName, permRead.Name, WizardConsts.LangKeyImport, true, MultiTenancySides.Both), autoSave: true);
|
||||
await InsertPermissionAsync(groupName, permImportName, permRead.Name, WizardConsts.LangKeyImport, permissionModules);
|
||||
|
||||
if (!existingPerms.Any(a => a.Name == permNoteName))
|
||||
await _repoPerm.InsertAsync(new PermissionDefinitionRecord(
|
||||
Guid.NewGuid(), groupName, permNoteName, permRead.Name, WizardConsts.LangKeyNote, true, MultiTenancySides.Both), autoSave: true);
|
||||
await InsertPermissionAsync(groupName, permNoteName, permRead.Name, WizardConsts.LangKeyNote, permissionModules);
|
||||
}
|
||||
|
||||
// // Permission Grants - Admin role için, sadece eksik olanları ekle
|
||||
|
|
@ -616,6 +613,20 @@ public class WizardDataSeeder : IDataSeedContributor, ITransientDependency
|
|||
_logger.LogInformation("Module '{ModuleId}' seed sirasinda olusturuldu.", cleaned);
|
||||
}
|
||||
|
||||
private async Task<PermissionDefinitionRecord> InsertPermissionAsync(
|
||||
string groupName,
|
||||
string name,
|
||||
string parentName,
|
||||
string displayName,
|
||||
string modules)
|
||||
{
|
||||
var permission = new PermissionDefinitionRecord(
|
||||
Guid.NewGuid(), groupName, name, parentName, displayName, true, MultiTenancySides.Both);
|
||||
permission.SetModules(modules);
|
||||
|
||||
return await _repoPerm.InsertAsync(permission, autoSave: true);
|
||||
}
|
||||
|
||||
private async Task BackfillMenuParentModuleIdAsync(ListFormWizardDto input)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(input.MenuParentCode) ||
|
||||
|
|
|
|||
Loading…
Reference in a new issue