提交roll日创建

This commit is contained in:
2026-07-14 18:46:20 +08:00
parent 6971daf9a7
commit 01444937bd
6 changed files with 66 additions and 11 deletions
@@ -114,6 +114,22 @@ public interface SysMenuMapper
*/
public int deleteMenuById(Long menuId);
/**
* 批量删除菜单信息
*
* @param menuIds 菜单ID集合
* @return 结果
*/
public int deleteMenuByIds(@Param("menuIds") List<Long> menuIds);
/**
* 根据父菜单ID查询子菜单
*
* @param parentId 父菜单ID
* @return 子菜单列表
*/
public List<SysMenu> selectChildrenByParentId(@Param("parentId") Long parentId);
/**
* 校验菜单名称是否唯一
*
@@ -1,6 +1,7 @@
package com.ruoyi.system.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.ruoyi.system.domain.SysRoleMenu;
/**
@@ -34,6 +35,14 @@ public interface SysRoleMenuMapper
*/
public int deleteRoleMenu(Long[] ids);
/**
* 通过菜单ID集合删除角色和菜单关联
*
* @param menuIds 菜单ID集合
* @return 结果
*/
public int deleteRoleMenuByMenuIds(@Param("menuIds") List<Long> menuIds);
/**
* 批量新增角色菜单信息
*
@@ -317,7 +317,7 @@ public class SysMenuServiceImpl implements ISysMenuService
}
/**
* 删除菜单管理信息
* 删除菜单管理信息,存在子菜单时级联删除子菜单及角色关联
*
* @param menuId 菜单ID
* @return 结果
@@ -325,7 +325,26 @@ public class SysMenuServiceImpl implements ISysMenuService
@Override
public int deleteMenuById(Long menuId)
{
return menuMapper.deleteMenuById(menuId);
List<Long> menuIds = new ArrayList<>();
collectAllMenuIds(menuId, menuIds);
if (!menuIds.isEmpty())
{
roleMenuMapper.deleteRoleMenuByMenuIds(menuIds);
}
return menuMapper.deleteMenuByIds(menuIds);
}
/**
* 递归收集当前菜单及其所有子菜单ID
*/
private void collectAllMenuIds(Long menuId, List<Long> menuIds)
{
menuIds.add(menuId);
List<SysMenu> children = menuMapper.selectChildrenByParentId(menuId);
for (SysMenu child : children)
{
collectAllMenuIds(child.getMenuId(), menuIds);
}
}
/**