diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Menus/MenuAppService.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Menus/MenuAppService.cs
index dcfa16f85..09b6e3b24 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Menus/MenuAppService.cs
+++ b/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);
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/en.json b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/en.json
index 06bdbfa79..71190f6ed 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/en.json
+++ b/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!",
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/zh-Hans.json b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/zh-Hans.json
index a44775103..98018d49a 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/zh-Hans.json
+++ b/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": "用户重复收藏菜单!",
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformErrorCodes.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformErrorCodes.cs
index 114d044c9..ae6898b25 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformErrorCodes.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformErrorCodes.cs
@@ -22,6 +22,10 @@ public static class PlatformErrorCodes
///
public const string MenuAchieveMaxDepth = Namespace + ":02003";
///
+ /// 当前菜单不能与上级菜单相同
+ ///
+ public const string CannotSetSelfParentMenu = Namespace + ":02004";
+ ///
/// 菜单元数据缺少必要的元素
///
public const string MenuMissingMetadata = Namespace + ":02101";