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.DynamicData;
|
||||||
using Sozsoft.Platform.Entities;
|
using Sozsoft.Platform.Entities;
|
||||||
using Sozsoft.Platform.Enums;
|
using Sozsoft.Platform.Enums;
|
||||||
|
using Sozsoft.Platform.Extensions;
|
||||||
using Volo.Abp;
|
using Volo.Abp;
|
||||||
using Volo.Abp.Content;
|
using Volo.Abp.Content;
|
||||||
using Volo.Abp.Domain.Repositories;
|
using Volo.Abp.Domain.Repositories;
|
||||||
|
|
@ -145,12 +146,17 @@ public class ListFormWizardAppService(
|
||||||
// Permission'ları tek seferde kontrol et ve oluştur
|
// Permission'ları tek seferde kontrol et ve oluştur
|
||||||
var existingPerms = await repoPerm.GetListAsync(a => a.GroupName == groupName);
|
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);
|
var permRead = existingPerms.FirstOrDefault(a => a.Name == code);
|
||||||
if (permRead == null)
|
if (permRead == null)
|
||||||
{
|
{
|
||||||
permRead = await repoPerm.InsertAsync(
|
var permReadRecord = new PermissionDefinitionRecord(GuidGenerator.Create(), groupName, code, null, nameLangKey, true, MultiTenancySides.Both);
|
||||||
new PermissionDefinitionRecord(GuidGenerator.Create(), groupName, code, null, nameLangKey, true, MultiTenancySides.Both),
|
permReadRecord.SetModules(permissionModules);
|
||||||
autoSave: false);
|
|
||||||
|
permRead = await repoPerm.InsertAsync(permReadRecord, autoSave: false);
|
||||||
inserted.PermissionNames.Add(permRead.Name);
|
inserted.PermissionNames.Add(permRead.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -186,9 +192,10 @@ public class ListFormWizardAppService(
|
||||||
if (existingPerms.Any(a => a.Name == permissionName))
|
if (existingPerms.Any(a => a.Name == permissionName))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
await repoPerm.InsertAsync(
|
var childPermission = new PermissionDefinitionRecord(GuidGenerator.Create(), groupName, permissionName, permRead.Name, langKey, true, MultiTenancySides.Both);
|
||||||
new PermissionDefinitionRecord(GuidGenerator.Create(), groupName, permissionName, permRead.Name, langKey, true, MultiTenancySides.Both),
|
childPermission.SetModules(permissionModules);
|
||||||
autoSave: false);
|
|
||||||
|
await repoPerm.InsertAsync(childPermission, autoSave: false);
|
||||||
inserted.PermissionNames.Add(permissionName);
|
inserted.PermissionNames.Add(permissionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ using Sozsoft.Languages.Entities;
|
||||||
using Sozsoft.Languages.Languages;
|
using Sozsoft.Languages.Languages;
|
||||||
using Sozsoft.Platform.Entities;
|
using Sozsoft.Platform.Entities;
|
||||||
using Sozsoft.Platform.Enums;
|
using Sozsoft.Platform.Enums;
|
||||||
|
using Sozsoft.Platform.Extensions;
|
||||||
using Sozsoft.Platform.ListForms;
|
using Sozsoft.Platform.ListForms;
|
||||||
using Volo.Abp.Data;
|
using Volo.Abp.Data;
|
||||||
using Volo.Abp.DependencyInjection;
|
using Volo.Abp.DependencyInjection;
|
||||||
|
|
@ -208,39 +209,35 @@ public class WizardDataSeeder : IDataSeedContributor, ITransientDependency
|
||||||
var permQueryable = await _repoPerm.GetQueryableAsync();
|
var permQueryable = await _repoPerm.GetQueryableAsync();
|
||||||
var existingPerms = permQueryable.Where(a => a.GroupName == groupName).ToList();
|
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);
|
var permRead = existingPerms.FirstOrDefault(a => a.Name == code);
|
||||||
if (permRead == null)
|
permRead ??= await InsertPermissionAsync(groupName, code, null, nameLangKey, permissionModules);
|
||||||
permRead = await _repoPerm.InsertAsync(new PermissionDefinitionRecord(
|
|
||||||
Guid.NewGuid(), groupName, code, null, nameLangKey, true, MultiTenancySides.Both), autoSave: true);
|
|
||||||
|
|
||||||
// CRUD üçlüsü her iki yolda da üretilir: Custom component de Form
|
// 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ış).
|
// üzerinden kayıt ekler, günceller ve siler (AppService.Create ile aynı davranış).
|
||||||
if (!existingPerms.Any(a => a.Name == permCreateName))
|
if (!existingPerms.Any(a => a.Name == permCreateName))
|
||||||
await _repoPerm.InsertAsync(new PermissionDefinitionRecord(
|
await InsertPermissionAsync(groupName, permCreateName, permRead.Name, WizardConsts.LangKeyCreate, permissionModules);
|
||||||
Guid.NewGuid(), groupName, permCreateName, permRead.Name, WizardConsts.LangKeyCreate, true, MultiTenancySides.Both), autoSave: true);
|
|
||||||
|
|
||||||
if (!existingPerms.Any(a => a.Name == permUpdateName))
|
if (!existingPerms.Any(a => a.Name == permUpdateName))
|
||||||
await _repoPerm.InsertAsync(new PermissionDefinitionRecord(
|
await InsertPermissionAsync(groupName, permUpdateName, permRead.Name, WizardConsts.LangKeyUpdate, permissionModules);
|
||||||
Guid.NewGuid(), groupName, permUpdateName, permRead.Name, WizardConsts.LangKeyUpdate, true, MultiTenancySides.Both), autoSave: true);
|
|
||||||
|
|
||||||
if (!existingPerms.Any(a => a.Name == permDeleteName))
|
if (!existingPerms.Any(a => a.Name == permDeleteName))
|
||||||
await _repoPerm.InsertAsync(new PermissionDefinitionRecord(
|
await InsertPermissionAsync(groupName, permDeleteName, permRead.Name, WizardConsts.LangKeyDelete, permissionModules);
|
||||||
Guid.NewGuid(), groupName, permDeleteName, permRead.Name, WizardConsts.LangKeyDelete, true, MultiTenancySides.Both), autoSave: true);
|
|
||||||
|
|
||||||
// Export/Import/Note yalnızca ListForm ekosisteminde karşılığı olan işlemlerdir.
|
// Export/Import/Note yalnızca ListForm ekosisteminde karşılığı olan işlemlerdir.
|
||||||
if (!isCustomComponent)
|
if (!isCustomComponent)
|
||||||
{
|
{
|
||||||
if (!existingPerms.Any(a => a.Name == permExportName))
|
if (!existingPerms.Any(a => a.Name == permExportName))
|
||||||
await _repoPerm.InsertAsync(new PermissionDefinitionRecord(
|
await InsertPermissionAsync(groupName, permExportName, permRead.Name, WizardConsts.LangKeyExport, permissionModules);
|
||||||
Guid.NewGuid(), groupName, permExportName, permRead.Name, WizardConsts.LangKeyExport, true, MultiTenancySides.Both), autoSave: true);
|
|
||||||
|
|
||||||
if (!existingPerms.Any(a => a.Name == permImportName))
|
if (!existingPerms.Any(a => a.Name == permImportName))
|
||||||
await _repoPerm.InsertAsync(new PermissionDefinitionRecord(
|
await InsertPermissionAsync(groupName, permImportName, permRead.Name, WizardConsts.LangKeyImport, permissionModules);
|
||||||
Guid.NewGuid(), groupName, permImportName, permRead.Name, WizardConsts.LangKeyImport, true, MultiTenancySides.Both), autoSave: true);
|
|
||||||
|
|
||||||
if (!existingPerms.Any(a => a.Name == permNoteName))
|
if (!existingPerms.Any(a => a.Name == permNoteName))
|
||||||
await _repoPerm.InsertAsync(new PermissionDefinitionRecord(
|
await InsertPermissionAsync(groupName, permNoteName, permRead.Name, WizardConsts.LangKeyNote, permissionModules);
|
||||||
Guid.NewGuid(), groupName, permNoteName, permRead.Name, WizardConsts.LangKeyNote, true, MultiTenancySides.Both), autoSave: true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Permission Grants - Admin role için, sadece eksik olanları ekle
|
// // 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);
|
_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)
|
private async Task BackfillMenuParentModuleIdAsync(ListFormWizardDto input)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(input.MenuParentCode) ||
|
if (string.IsNullOrWhiteSpace(input.MenuParentCode) ||
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue