Browse Source

fix(platform): Fix the same menu error

- The current menu cannot be the same as the upper-level menu
pull/1282/head
colin 8 months ago
parent
commit
3afc94020a
  1. 9
      aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Menus/MenuAppService.cs
  2. 1
      aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/en.json
  3. 1
      aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/zh-Hans.json
  4. 4
      aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformErrorCodes.cs

9
aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Menus/MenuAppService.cs

@ -210,8 +210,15 @@ public class MenuAppService : PlatformApplicationServiceBase, IMenuAppService
{
menu.Component = input.Component;
}
if (menu.ParentId != input.ParentId)
{
if (input.ParentId == menu.Id)
{
throw new BusinessException(PlatformErrorCodes.CannotSetSelfParentMenu, "The current menu cannot be the same as the upper-level menu!");
}
menu.ParentId = input.ParentId;
}
menu.ParentId = input.ParentId;
menu.IsPublic = input.IsPublic;
await MenuManager.UpdateAsync(menu);

1
aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/en.json

@ -6,6 +6,7 @@
"Platform:02001": "The same menu exists in the sibling directory: {Name}!",
"Platform:02002": "You are not allowed to delete menu nodes when there are other submenus!",
"Platform:02003": "The menu level has reached the specified maximum: {Depth}!",
"Platform:02004": "The current menu cannot be the same as the upper-level menu!",
"Platform:02101": "The menu metadata is missing the necessary element :{Name}, which is defined in the data dictionary :{DataName}!",
"Platform:03001": "The metadata format does not match!",
"Platform:04400": "The user favorites the menu repeatedly!",

1
aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/zh-Hans.json

@ -6,6 +6,7 @@
"Platform:02001": "同级目录下存在相同的菜单: {Name}!",
"Platform:02002": "在有其他子菜单的情况下,不允许删除菜单节点!",
"Platform:02003": "菜单层级已达到规定最大值: {Depth}!",
"Platform:02004": "当前菜单不能与上级菜单相同!",
"Platform:02101": "菜单元数据缺少必要的元素: {Name},此选项在数据字典:{DataName} 中定义!",
"Platform:03001": "元数据格式不匹配!",
"Platform:04400": "用户重复收藏菜单!",

4
aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformErrorCodes.cs

@ -22,6 +22,10 @@ public static class PlatformErrorCodes
/// </summary>
public const string MenuAchieveMaxDepth = Namespace + ":02003";
/// <summary>
/// 当前菜单不能与上级菜单相同
/// </summary>
public const string CannotSetSelfParentMenu = Namespace + ":02004";
/// <summary>
/// 菜单元数据缺少必要的元素
/// </summary>
public const string MenuMissingMetadata = Namespace + ":02101";

Loading…
Cancel
Save