菜单管理修改接口优化

This commit is contained in:
2025-12-18 14:56:15 +08:00
parent d6fbfb1427
commit 37d08b8545

View File

@@ -284,10 +284,15 @@ public class SysMenuServiceImpl implements ISysMenuService {
@Override
public int updateMenu(SysMenu menu) {
//路径Path唯一性判断
SysMenu sysMenu = menuMapper.selectMenuByPath(menu.getPath());
if (sysMenu != null && !menu.getMenuId().equals(sysMenu.getMenuId())) {
return -1;
String path = menu.getPath();
if (StringUtils.isNotBlank(path)) {
SysMenu sysMenu = menuMapper.selectMenuByPath(menu.getPath());
// 先判断sysMenu是否不为null再比较menuId
if (sysMenu != null && !menu.getMenuId().equals(sysMenu.getMenuId())) {
return -1; // 路由地址已存在
}
}
// 执行更新
return menuMapper.updateMenu(menu);
}