菜单管理->修改、新增时路由地址唯一性检验

This commit is contained in:
2025-12-18 10:20:52 +08:00
parent 515f03a5cd
commit 1e6a5972b9
4 changed files with 46 additions and 8 deletions

View File

@@ -84,6 +84,14 @@ public interface SysMenuMapper {
*/
public SysMenu selectMenuById(Long menuId);
/**
* 根据路径Path查询信息
*
* @param path 路径
* @return 菜单信息
*/
public SysMenu selectMenuByPath(String path);
/**
* 是否存在菜单子节点
*

View File

@@ -3,6 +3,7 @@ package com.core.system.service.impl;
import java.util.*;
import java.util.stream.Collectors;
import com.core.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -266,6 +267,11 @@ public class SysMenuServiceImpl implements ISysMenuService {
*/
@Override
public int insertMenu(SysMenu menu) {
//路径Path唯一性判断
SysMenu sysMenu = menuMapper.selectMenuByPath(menu.getPath());
if (sysMenu != null){
return -1;
}
return menuMapper.insertMenu(menu);
}
@@ -277,6 +283,11 @@ public class SysMenuServiceImpl implements ISysMenuService {
*/
@Override
public int updateMenu(SysMenu menu) {
//路径Path唯一性判断
SysMenu sysMenu = menuMapper.selectMenuByPath(menu.getPath());
if (sysMenu != null){
return -1;
}
return menuMapper.updateMenu(menu);
}

View File

@@ -174,6 +174,11 @@
and rm.role_id = #{roleId}
</select>
<select id="selectMenuByPath" parameterType="String" resultMap="SysMenuResult">
<include refid="selectMenuVo"/>
where path = #{path}
</select>
<select id="selectMenuById" parameterType="Long" resultMap="SysMenuResult">
<include refid="selectMenuVo"/>
where menu_id = #{menuId}