fix(system): 修复修改菜单时父级菜单选择为当前菜单的问题
- 在修改菜单时增加了一个判断,如果父级菜单 ID与当前菜单 ID 相同,则抛出异常 - 异常信息为 "父级菜单不能为当前菜单",避免了逻辑上的错误
This commit is contained in:
@@ -241,7 +241,9 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
|||||||
|
|
||||||
menuForm.setComponent(null);
|
menuForm.setComponent(null);
|
||||||
}
|
}
|
||||||
|
if (Objects.equals(menuForm.getParentId(), menuForm.getId())){
|
||||||
|
throw new RuntimeException("父级菜单不能为当前菜单");
|
||||||
|
}
|
||||||
Menu entity = menuConverter.toEntity(menuForm);
|
Menu entity = menuConverter.toEntity(menuForm);
|
||||||
String treePath = generateMenuTreePath(menuForm.getParentId());
|
String treePath = generateMenuTreePath(menuForm.getParentId());
|
||||||
entity.setTreePath(treePath);
|
entity.setTreePath(treePath);
|
||||||
|
|||||||
Reference in New Issue
Block a user