Menu Entitysinden MenuGroup kaldırıldı

This commit is contained in:
Sedat Öztürk 2025-10-12 17:44:34 +03:00
parent 3e6cce6982
commit d9d25b9427
13 changed files with 258 additions and 394 deletions

View file

@ -21,5 +21,4 @@ public class MenuDto : FullAuditedEntityDto<Guid>
public string UserId { get; set; } // External kullanici id (orn: ali.akman. ihtiyaca gore guid veya int de olabilir) public string UserId { get; set; } // External kullanici id (orn: ali.akman. ihtiyaca gore guid veya int de olabilir)
public string RoleId { get; set; } // External role id (orn: ihracat) public string RoleId { get; set; } // External role id (orn: ihracat)
public string CultureName { get; set; } // Bu tanim hangi dil icin "en", "tr" public string CultureName { get; set; } // Bu tanim hangi dil icin "en", "tr"
public string[] Group { get; set; } // Menu grubu (her tenant farklı menu grupları kullanabilir)
} }

View file

@ -4,11 +4,15 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Kurs.Languages.Entities; using Kurs.Languages.Entities;
using Kurs.Platform.Entities; using Kurs.Platform.Entities;
using Kurs.Platform.Extensions;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
using Volo.Abp.MultiTenancy;
using Volo.Abp.PermissionManagement;
using Volo.Abp.TenantManagement;
using static Kurs.Platform.Data.Seeds.SeedConsts; using static Kurs.Platform.Data.Seeds.SeedConsts;
namespace Kurs.Platform.Menus; namespace Kurs.Platform.Menus;
@ -22,30 +26,56 @@ public class MenuAppService : CrudAppService<
{ {
private readonly IRepository<Menu, Guid> _menuRepository; private readonly IRepository<Menu, Guid> _menuRepository;
private readonly IRepository<LanguageKey, Guid> _repositoryKey; private readonly IRepository<LanguageKey, Guid> _repositoryKey;
private readonly ITenantRepository _tenantRepository;
private readonly IPermissionDefinitionRecordRepository _permissionRepository;
public MenuAppService( public MenuAppService(
IRepository<Menu, Guid> menuRepository, IRepository<Menu, Guid> menuRepository,
IRepository<LanguageKey, Guid> languageKeyRepository) : base(menuRepository) IRepository<LanguageKey, Guid> languageKeyRepository,
ITenantRepository tenantRepository,
IPermissionDefinitionRecordRepository permissionRepository
) : base(menuRepository)
{ {
_menuRepository = menuRepository; _menuRepository = menuRepository;
_repositoryKey = languageKeyRepository; _repositoryKey = languageKeyRepository;
_tenantRepository = tenantRepository;
_permissionRepository = permissionRepository;
CreatePolicyName = $"{AppCodes.Menus.Menu}.Create"; CreatePolicyName = $"{AppCodes.Menus.Menu}.Create";
UpdatePolicyName = $"{AppCodes.Menus.Menu}.Update"; UpdatePolicyName = $"{AppCodes.Menus.Menu}.Update";
DeletePolicyName = $"{AppCodes.Menus.Menu}.Delete"; DeletePolicyName = $"{AppCodes.Menus.Menu}.Delete";
} }
public async Task<PagedResultDto<MenuDto>> GetListByGroupAsync(PagedAndSortedResultRequestDto input, string? group = null) public override async Task<PagedResultDto<MenuDto>> GetListAsync(PagedAndSortedResultRequestDto input)
{ {
await CheckGetListPolicyAsync(); await CheckGetListPolicyAsync();
var query = await CreateFilteredQueryAsync(input); var query = await CreateFilteredQueryAsync(input);
query = query.Where(a => !a.IsDisabled); query = query.Where(a => !a.IsDisabled);
// Group filtrelemesi ekle //Tenant üzerinden MenuGrup bilgisi alınıp sadece o menüler listelenecek
if (!string.IsNullOrEmpty(group)) // 🔹 Tenant'a göre filtrele
if (CurrentTenant.IsAvailable)
{ {
query = query.Where(a => a.Group.Contains(group) || a.Group.Any(g => g == group)); var tenant = await _tenantRepository.FindAsync(CurrentTenant.Id.Value);
if (tenant != null)
{
var tenantMenuGroup = tenant.GetMenuGroup();
if (!tenantMenuGroup.IsNullOrWhiteSpace())
{
var permissionRecords = await _permissionRepository.GetListAsync();
var allowedPermissionNames = permissionRecords
.Where(p => p.GetMenuGroup().Contains(tenantMenuGroup))
.Select(p => p.Name)
.Distinct()
.ToList();
query = query.Where(menu =>
string.IsNullOrEmpty(menu.RequiredPermissionName) ||
allowedPermissionNames.Contains(menu.RequiredPermissionName));
}
}
} }
var totalCount = await AsyncExecuter.CountAsync(query); var totalCount = await AsyncExecuter.CountAsync(query);
@ -91,11 +121,6 @@ public class MenuAppService : CrudAppService<
); );
} }
public override async Task<PagedResultDto<MenuDto>> GetListAsync(PagedAndSortedResultRequestDto input)
{
return await GetListByGroupAsync(input, null);
}
public override async Task<MenuDto> CreateAsync(MenuDto input) public override async Task<MenuDto> CreateAsync(MenuDto input)
{ {
await CheckCreatePolicyAsync(); await CheckCreatePolicyAsync();

File diff suppressed because it is too large Load diff

View file

@ -470,7 +470,6 @@ public class HostDataSeeder : IDataSeedContributor, ITransientDependency
Icon = item.Icon, Icon = item.Icon,
RequiredPermissionName = item.RequiredPermissionName, RequiredPermissionName = item.RequiredPermissionName,
IsDisabled = item.IsDisabled, IsDisabled = item.IsDisabled,
Group = item.Group
}); });
} }
} }

View file

@ -66,7 +66,6 @@ public class MenuSeedDto
public string Icon { get; set; } public string Icon { get; set; }
public string RequiredPermissionName { get; set; } public string RequiredPermissionName { get; set; }
public bool IsDisabled { get; set; } public bool IsDisabled { get; set; }
public string[] Group { get; set; }
} }
public class PermissionGroupDefinitionRecordSeedDto public class PermissionGroupDefinitionRecordSeedDto

View file

@ -2938,7 +2938,6 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
new () { Key="Erp", Name="Erp" }, new () { Key="Erp", Name="Erp" },
}), }),
}), }),
ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto
{ {
AllowReordering = true, AllowReordering = true,
@ -4158,6 +4157,7 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
new EditingFormItemDto { Order=3, DataField="DisplayName", ColSpan=2, IsRequired=true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton }, new EditingFormItemDto { Order=3, DataField="DisplayName", ColSpan=2, IsRequired=true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
new EditingFormItemDto { Order=4, DataField="IsEnabled", ColSpan=2, IsRequired=false, EditorType2=EditorTypes.dxCheckBox }, new EditingFormItemDto { Order=4, DataField="IsEnabled", ColSpan=2, IsRequired=false, EditorType2=EditorTypes.dxCheckBox },
new EditingFormItemDto { Order=5, DataField="MultiTenancySide", ColSpan=2, IsRequired=false, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton }, new EditingFormItemDto { Order=5, DataField="MultiTenancySide", ColSpan=2, IsRequired=false, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
new EditingFormItemDto { Order=6, DataField="MenuGroup", ColSpan=2, IsRequired=true, EditorType2=EditorTypes.dxTagBox },
] ]
} }
}), }),
@ -4432,6 +4432,47 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
{ {
IsPivot = true IsPivot = true
}) })
},
new ListFormField
{
ListFormCode = listFormPermissions.ListFormCode,
RoleId = null,
UserId = null,
CultureName = LanguageCodes.En,
SourceDbType = DbType.Int16,
FieldName = "MenuGroup",
Width = 85,
ListOrderNo = 8,
Visible = true,
IsActive = true,
IsDeleted = false,
LookupJson = JsonSerializer.Serialize(new LookupDto
{
DataSourceType = UiLookupDataSourceTypeEnum.StaticData,
DisplayExpr = "name",
ValueExpr = "key",
LookupQuery = JsonSerializer.Serialize(new LookupDataDto[] {
new () { Key="Kurs",Name="Kurs" },
new () { Key="Erp",Name="Erp" },
}),
}),
ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto
{
AllowReordering = true,
}),
PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto
{
C = AbpIdentity.Permissions.Create,
R = AbpIdentity.Permissions.Default,
U = AbpIdentity.Permissions.Update,
E = true,
I = true,
Deny = false
}),
PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto
{
IsPivot = true
})
} }
}); });
#endregion #endregion

View file

@ -21,6 +21,5 @@ public class Menu : FullAuditedEntity<Guid>
public string UserId { get; set; } // External kullanici id (orn: ali.akman. ihtiyaca gore guid veya int de olabilir) public string UserId { get; set; } // External kullanici id (orn: ali.akman. ihtiyaca gore guid veya int de olabilir)
public string RoleId { get; set; } // External role id (orn: ihracat) public string RoleId { get; set; } // External role id (orn: ihracat)
public string CultureName { get; set; } // Bu tanim hangi dil icin "en", "tr" public string CultureName { get; set; } // Bu tanim hangi dil icin "en", "tr"
public string[] Group { get; set; } // Menu grubu (her tenant farklı menu grupları kullanabilir)
} }

View file

@ -303,7 +303,6 @@ public class PlatformDbContext :
b.Property(a => a.UserId).HasMaxLength(256); b.Property(a => a.UserId).HasMaxLength(256);
b.Property(a => a.RoleId).HasMaxLength(256); b.Property(a => a.RoleId).HasMaxLength(256);
b.Property(a => a.CultureName).HasMaxLength(50); b.Property(a => a.CultureName).HasMaxLength(50);
b.Property(a => a.Group).HasMaxLength(64);
}); });
builder.Entity<DataSource>(b => builder.Entity<DataSource>(b =>

View file

@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore;
namespace Kurs.Platform.Migrations namespace Kurs.Platform.Migrations
{ {
[DbContext(typeof(PlatformDbContext))] [DbContext(typeof(PlatformDbContext))]
[Migration("20251011214108_Initial")] [Migration("20251012075048_Initial")]
partial class Initial partial class Initial
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -4482,10 +4482,6 @@ namespace Kurs.Platform.Migrations
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("nvarchar(50)"); .HasColumnType("nvarchar(50)");
b.PrimitiveCollection<string>("Group")
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
b.Property<string>("Icon") b.Property<string>("Icon")
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("nvarchar(50)"); .HasColumnType("nvarchar(50)");

View file

@ -1689,7 +1689,6 @@ namespace Kurs.Platform.Migrations
UserId = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true), UserId = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
RoleId = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true), RoleId = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
CultureName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true), CultureName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
Group = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false), CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true), LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),

View file

@ -4479,10 +4479,6 @@ namespace Kurs.Platform.Migrations
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("nvarchar(50)"); .HasColumnType("nvarchar(50)");
b.PrimitiveCollection<string>("Group")
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
b.Property<string>("Icon") b.Property<string>("Icon")
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("nvarchar(50)"); .HasColumnType("nvarchar(50)");

View file

@ -45,16 +45,15 @@ export class MenuService {
{ apiName: this.apiName }, { apiName: this.apiName },
) )
getList = (input: PagedAndSortedResultRequestDto, group?: string | null) => getList = (input: PagedAndSortedResultRequestDto) =>
apiService.fetchData<PagedResultDto<MenuDto>, PagedAndSortedResultRequestDto>( apiService.fetchData<PagedResultDto<MenuDto>, PagedAndSortedResultRequestDto>(
{ {
method: 'GET', method: 'GET',
url: '/api/app/menu/by-group', url: '/api/app/menu',
params: { params: {
sorting: input.sorting, sorting: input.sorting,
skipCount: input.skipCount, skipCount: input.skipCount,
maxResultCount: input.maxResultCount, maxResultCount: input.maxResultCount
group: group,
}, },
}, },
{ apiName: this.apiName }, { apiName: this.apiName },
@ -80,7 +79,6 @@ export const getMenus = async (skipCount = 0, maxResultCount = 1000, sorting = '
sorting, sorting,
skipCount, skipCount,
maxResultCount, maxResultCount,
}, }
null, //tenant.menuGroup ?? null,
) )
} }

View file

@ -71,33 +71,20 @@ export const abpConfigModel: AbpConfigModel = {
mainMenu: [], mainMenu: [],
}, },
setMenu: action((state, payload) => { setMenu: action((state, payload) => {
// const formMenu: NavigationTree = {
// key: 'form',
// path: 'form/Form-0001',
// title: 'Form',
// type: 'item',
// translateKey: 'form',
// icon: 'form',
// subMenu: [],
// authority: [],
// }
// state.menu.mainMenu = [...payload, formMenu]
state.menu.mainMenu = [...payload] state.menu.mainMenu = [...payload]
}), }),
getMenu: thunk(async (actions, _, { injections, getState, getStoreState }) => { getMenu: thunk(async (actions, _, { injections, getState, getStoreState }) => {
const { session, tenant } = getStoreState().auth const { signedIn } = getStoreState().auth.session
if (!session.signedIn) { if (!signedIn) {
return return
} }
const menuGroup = tenant.menuGroup ?? null
const result = await injections.menuService.getList( const result = await injections.menuService.getList(
{ {
sorting: 'order', sorting: 'order',
skipCount: 0, skipCount: 0,
maxResultCount: 1000, maxResultCount: 1000,
}, }
menuGroup,
) )
const texts = getState().texts const texts = getState().texts