mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 08:13:44 +08:00 
			
		
		
		
	@@ -51,8 +51,8 @@ public class SysMenuController extends BaseController {
 | 
				
			|||||||
     * 获取菜单列表
 | 
					     * 获取菜单列表
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @SaCheckRole(value = {
 | 
					    @SaCheckRole(value = {
 | 
				
			||||||
            TenantConstants.SUPER_ADMIN_ROLE_KEY,
 | 
					        TenantConstants.SUPER_ADMIN_ROLE_KEY,
 | 
				
			||||||
            TenantConstants.TENANT_ADMIN_ROLE_KEY
 | 
					        TenantConstants.TENANT_ADMIN_ROLE_KEY
 | 
				
			||||||
    }, mode = SaMode.OR)
 | 
					    }, mode = SaMode.OR)
 | 
				
			||||||
    @SaCheckPermission("system:menu:list")
 | 
					    @SaCheckPermission("system:menu:list")
 | 
				
			||||||
    @GetMapping("/list")
 | 
					    @GetMapping("/list")
 | 
				
			||||||
@@ -67,8 +67,8 @@ public class SysMenuController extends BaseController {
 | 
				
			|||||||
     * @param menuId 菜单ID
 | 
					     * @param menuId 菜单ID
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @SaCheckRole(value = {
 | 
					    @SaCheckRole(value = {
 | 
				
			||||||
            TenantConstants.SUPER_ADMIN_ROLE_KEY,
 | 
					        TenantConstants.SUPER_ADMIN_ROLE_KEY,
 | 
				
			||||||
            TenantConstants.TENANT_ADMIN_ROLE_KEY
 | 
					        TenantConstants.TENANT_ADMIN_ROLE_KEY
 | 
				
			||||||
    }, mode = SaMode.OR)
 | 
					    }, mode = SaMode.OR)
 | 
				
			||||||
    @SaCheckPermission("system:menu:query")
 | 
					    @SaCheckPermission("system:menu:query")
 | 
				
			||||||
    @GetMapping(value = "/{menuId}")
 | 
					    @GetMapping(value = "/{menuId}")
 | 
				
			||||||
@@ -173,4 +173,22 @@ public class SysMenuController extends BaseController {
 | 
				
			|||||||
    public record MenuTreeSelectVo(List<Long> checkedKeys, List<Tree<Long>> menus) {
 | 
					    public record MenuTreeSelectVo(List<Long> checkedKeys, List<Tree<Long>> menus) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 批量级联删除菜单
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param menuIds 菜单ID串
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
 | 
				
			||||||
 | 
					    @SaCheckPermission("system:menu:remove")
 | 
				
			||||||
 | 
					    @Log(title = "菜单管理", businessType = BusinessType.DELETE)
 | 
				
			||||||
 | 
					    @DeleteMapping("/cascade/{menuIds}")
 | 
				
			||||||
 | 
					    public R<Void> remove(@PathVariable("menuIds") Long[] menuIds) {
 | 
				
			||||||
 | 
					        List<Long> menuIdList = List.of(menuIds);
 | 
				
			||||||
 | 
					        if (menuService.hasChildByMenuId(menuIdList)) {
 | 
				
			||||||
 | 
					            return R.warn("存在子菜单,不允许删除");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        menuService.deleteMenuById(menuIdList);
 | 
				
			||||||
 | 
					        return R.ok();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,11 @@
 | 
				
			|||||||
package org.dromara.system.mapper;
 | 
					package org.dromara.system.mapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 | 
				
			||||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
 | 
					import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
 | 
				
			||||||
import org.dromara.system.domain.SysRoleMenu;
 | 
					import org.dromara.system.domain.SysRoleMenu;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * 角色与菜单关联表 数据层
 | 
					 * 角色与菜单关联表 数据层
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
@@ -10,4 +13,15 @@ import org.dromara.system.domain.SysRoleMenu;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
public interface SysRoleMenuMapper extends BaseMapperPlus<SysRoleMenu, SysRoleMenu> {
 | 
					public interface SysRoleMenuMapper extends BaseMapperPlus<SysRoleMenu, SysRoleMenu> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 根据菜单ID串删除关联关系
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return 结果
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    default int deleteByMenuIds(List<Long> menuIds) {
 | 
				
			||||||
 | 
					        LambdaUpdateWrapper<SysRoleMenu> lqw = new LambdaUpdateWrapper<SysRoleMenu>()
 | 
				
			||||||
 | 
					            .in(SysRoleMenu::getMenuId, menuIds);
 | 
				
			||||||
 | 
					        return this.delete(lqw);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -105,6 +105,14 @@ public interface ISysMenuService {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    boolean hasChildByMenuId(Long menuId);
 | 
					    boolean hasChildByMenuId(Long menuId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 是否存在菜单子节点
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param menuIds 菜单ID串
 | 
				
			||||||
 | 
					     * @return 结果 true 存在 false 不存在
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    boolean hasChildByMenuId(List<Long> menuIds);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 查询菜单是否存在角色
 | 
					     * 查询菜单是否存在角色
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@@ -137,6 +145,14 @@ public interface ISysMenuService {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    int deleteMenuById(Long menuId);
 | 
					    int deleteMenuById(Long menuId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 批量删除菜单管理信息
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param menuIds 菜单ID串
 | 
				
			||||||
 | 
					     * @return 结果
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    void deleteMenuById(List<Long> menuIds);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 校验菜单名称是否唯一
 | 
					     * 校验菜单名称是否唯一
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,7 @@ import org.dromara.system.mapper.SysRoleMenuMapper;
 | 
				
			|||||||
import org.dromara.system.mapper.SysTenantPackageMapper;
 | 
					import org.dromara.system.mapper.SysTenantPackageMapper;
 | 
				
			||||||
import org.dromara.system.service.ISysMenuService;
 | 
					import org.dromara.system.service.ISysMenuService;
 | 
				
			||||||
import org.springframework.stereotype.Service;
 | 
					import org.springframework.stereotype.Service;
 | 
				
			||||||
 | 
					import org.springframework.transaction.annotation.Transactional;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.*;
 | 
					import java.util.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -173,11 +174,15 @@ public class SysMenuServiceImpl implements ISysMenuService {
 | 
				
			|||||||
        if (tenantPackage.getMenuCheckStrictly()) {
 | 
					        if (tenantPackage.getMenuCheckStrictly()) {
 | 
				
			||||||
            parentIds = baseMapper.selectObjs(new LambdaQueryWrapper<SysMenu>()
 | 
					            parentIds = baseMapper.selectObjs(new LambdaQueryWrapper<SysMenu>()
 | 
				
			||||||
                .select(SysMenu::getParentId)
 | 
					                .select(SysMenu::getParentId)
 | 
				
			||||||
                .in(SysMenu::getMenuId, menuIds), x -> {return Convert.toLong(x);});
 | 
					                .in(SysMenu::getMenuId, menuIds), x -> {
 | 
				
			||||||
 | 
					                return Convert.toLong(x);
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return baseMapper.selectObjs(new LambdaQueryWrapper<SysMenu>()
 | 
					        return baseMapper.selectObjs(new LambdaQueryWrapper<SysMenu>()
 | 
				
			||||||
            .in(SysMenu::getMenuId, menuIds)
 | 
					            .in(SysMenu::getMenuId, menuIds)
 | 
				
			||||||
            .notIn(CollUtil.isNotEmpty(parentIds), SysMenu::getMenuId, parentIds), x -> {return Convert.toLong(x);});
 | 
					            .notIn(CollUtil.isNotEmpty(parentIds), SysMenu::getMenuId, parentIds), x -> {
 | 
				
			||||||
 | 
					            return Convert.toLong(x);
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -278,6 +283,17 @@ public class SysMenuServiceImpl implements ISysMenuService {
 | 
				
			|||||||
        return baseMapper.exists(new LambdaQueryWrapper<SysMenu>().eq(SysMenu::getParentId, menuId));
 | 
					        return baseMapper.exists(new LambdaQueryWrapper<SysMenu>().eq(SysMenu::getParentId, menuId));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 是否存在菜单子节点
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param menuIds 菜单ID串
 | 
				
			||||||
 | 
					     * @return 结果
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean hasChildByMenuId(List<Long> menuIds) {
 | 
				
			||||||
 | 
					        return baseMapper.exists(new LambdaQueryWrapper<SysMenu>().in(SysMenu::getParentId, menuIds).notIn(SysMenu::getMenuId, menuIds));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 查询菜单使用数量
 | 
					     * 查询菜单使用数量
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@@ -324,6 +340,19 @@ public class SysMenuServiceImpl implements ISysMenuService {
 | 
				
			|||||||
        return baseMapper.deleteById(menuId);
 | 
					        return baseMapper.deleteById(menuId);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 批量删除菜单管理信息
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param menuIds 菜单ID串
 | 
				
			||||||
 | 
					     * @return 结果
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    @Transactional(rollbackFor = Exception.class)
 | 
				
			||||||
 | 
					    public void deleteMenuById(List<Long> menuIds) {
 | 
				
			||||||
 | 
					        baseMapper.deleteByIds(menuIds);
 | 
				
			||||||
 | 
					        roleMenuMapper.deleteByMenuIds(menuIds);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 校验菜单名称是否唯一
 | 
					     * 校验菜单名称是否唯一
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user