parent
cea4855f57
commit
336b2e8cc3
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验菜单名称是否唯一
|
* 校验菜单名称是否唯一
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user