Menu Entitysinden MenuGroup kaldırıldı
This commit is contained in:
parent
3e6cce6982
commit
d9d25b9427
13 changed files with 258 additions and 394 deletions
|
|
@ -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 RoleId { get; set; } // External role id (orn: ihracat)
|
||||
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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,15 @@ using System.Linq;
|
|||
using System.Threading.Tasks;
|
||||
using Kurs.Languages.Entities;
|
||||
using Kurs.Platform.Entities;
|
||||
using Kurs.Platform.Extensions;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Volo.Abp.MultiTenancy;
|
||||
using Volo.Abp.PermissionManagement;
|
||||
using Volo.Abp.TenantManagement;
|
||||
using static Kurs.Platform.Data.Seeds.SeedConsts;
|
||||
|
||||
namespace Kurs.Platform.Menus;
|
||||
|
|
@ -22,30 +26,56 @@ public class MenuAppService : CrudAppService<
|
|||
{
|
||||
private readonly IRepository<Menu, Guid> _menuRepository;
|
||||
private readonly IRepository<LanguageKey, Guid> _repositoryKey;
|
||||
private readonly ITenantRepository _tenantRepository;
|
||||
private readonly IPermissionDefinitionRecordRepository _permissionRepository;
|
||||
|
||||
public MenuAppService(
|
||||
IRepository<Menu, Guid> menuRepository,
|
||||
IRepository<LanguageKey, Guid> languageKeyRepository) : base(menuRepository)
|
||||
IRepository<LanguageKey, Guid> languageKeyRepository,
|
||||
ITenantRepository tenantRepository,
|
||||
IPermissionDefinitionRecordRepository permissionRepository
|
||||
) : base(menuRepository)
|
||||
{
|
||||
_menuRepository = menuRepository;
|
||||
_repositoryKey = languageKeyRepository;
|
||||
_tenantRepository = tenantRepository;
|
||||
_permissionRepository = permissionRepository;
|
||||
|
||||
CreatePolicyName = $"{AppCodes.Menus.Menu}.Create";
|
||||
UpdatePolicyName = $"{AppCodes.Menus.Menu}.Update";
|
||||
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();
|
||||
|
||||
var query = await CreateFilteredQueryAsync(input);
|
||||
query = query.Where(a => !a.IsDisabled);
|
||||
|
||||
// Group filtrelemesi ekle
|
||||
if (!string.IsNullOrEmpty(group))
|
||||
//Tenant üzerinden MenuGrup bilgisi alınıp sadece o menüler listelenecek
|
||||
// 🔹 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);
|
||||
|
|
@ -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)
|
||||
{
|
||||
await CheckCreatePolicyAsync();
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -470,7 +470,6 @@ public class HostDataSeeder : IDataSeedContributor, ITransientDependency
|
|||
Icon = item.Icon,
|
||||
RequiredPermissionName = item.RequiredPermissionName,
|
||||
IsDisabled = item.IsDisabled,
|
||||
Group = item.Group
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,6 @@ public class MenuSeedDto
|
|||
public string Icon { get; set; }
|
||||
public string RequiredPermissionName { get; set; }
|
||||
public bool IsDisabled { get; set; }
|
||||
public string[] Group { get; set; }
|
||||
}
|
||||
|
||||
public class PermissionGroupDefinitionRecordSeedDto
|
||||
|
|
|
|||
|
|
@ -2938,7 +2938,6 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
|
|||
new () { Key="Erp", Name="Erp" },
|
||||
}),
|
||||
}),
|
||||
|
||||
ColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto
|
||||
{
|
||||
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=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=6, DataField="MenuGroup", ColSpan=2, IsRequired=true, EditorType2=EditorTypes.dxTagBox },
|
||||
]
|
||||
}
|
||||
}),
|
||||
|
|
@ -4432,6 +4432,47 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency
|
|||
{
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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 RoleId { get; set; } // External role id (orn: ihracat)
|
||||
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)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -303,7 +303,6 @@ public class PlatformDbContext :
|
|||
b.Property(a => a.UserId).HasMaxLength(256);
|
||||
b.Property(a => a.RoleId).HasMaxLength(256);
|
||||
b.Property(a => a.CultureName).HasMaxLength(50);
|
||||
b.Property(a => a.Group).HasMaxLength(64);
|
||||
});
|
||||
|
||||
builder.Entity<DataSource>(b =>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore;
|
|||
namespace Kurs.Platform.Migrations
|
||||
{
|
||||
[DbContext(typeof(PlatformDbContext))]
|
||||
[Migration("20251011214108_Initial")]
|
||||
[Migration("20251012075048_Initial")]
|
||||
partial class Initial
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
|
@ -4482,10 +4482,6 @@ namespace Kurs.Platform.Migrations
|
|||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.PrimitiveCollection<string>("Group")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("nvarchar(64)");
|
||||
|
||||
b.Property<string>("Icon")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
|
@ -1689,7 +1689,6 @@ namespace Kurs.Platform.Migrations
|
|||
UserId = 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),
|
||||
Group = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
|
||||
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
|
|
@ -4479,10 +4479,6 @@ namespace Kurs.Platform.Migrations
|
|||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.PrimitiveCollection<string>("Group")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("nvarchar(64)");
|
||||
|
||||
b.Property<string>("Icon")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
|
|
|||
|
|
@ -45,16 +45,15 @@ export class MenuService {
|
|||
{ apiName: this.apiName },
|
||||
)
|
||||
|
||||
getList = (input: PagedAndSortedResultRequestDto, group?: string | null) =>
|
||||
getList = (input: PagedAndSortedResultRequestDto) =>
|
||||
apiService.fetchData<PagedResultDto<MenuDto>, PagedAndSortedResultRequestDto>(
|
||||
{
|
||||
method: 'GET',
|
||||
url: '/api/app/menu/by-group',
|
||||
url: '/api/app/menu',
|
||||
params: {
|
||||
sorting: input.sorting,
|
||||
skipCount: input.skipCount,
|
||||
maxResultCount: input.maxResultCount,
|
||||
group: group,
|
||||
maxResultCount: input.maxResultCount
|
||||
},
|
||||
},
|
||||
{ apiName: this.apiName },
|
||||
|
|
@ -80,7 +79,6 @@ export const getMenus = async (skipCount = 0, maxResultCount = 1000, sorting = '
|
|||
sorting,
|
||||
skipCount,
|
||||
maxResultCount,
|
||||
},
|
||||
null, //tenant.menuGroup ?? null,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,33 +71,20 @@ export const abpConfigModel: AbpConfigModel = {
|
|||
mainMenu: [],
|
||||
},
|
||||
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]
|
||||
}),
|
||||
getMenu: thunk(async (actions, _, { injections, getState, getStoreState }) => {
|
||||
const { session, tenant } = getStoreState().auth
|
||||
if (!session.signedIn) {
|
||||
const { signedIn } = getStoreState().auth.session
|
||||
if (!signedIn) {
|
||||
return
|
||||
}
|
||||
|
||||
const menuGroup = tenant.menuGroup ?? null
|
||||
const result = await injections.menuService.getList(
|
||||
{
|
||||
sorting: 'order',
|
||||
skipCount: 0,
|
||||
maxResultCount: 1000,
|
||||
},
|
||||
menuGroup,
|
||||
}
|
||||
)
|
||||
|
||||
const texts = getState().texts
|
||||
|
|
|
|||
Loading…
Reference in a new issue