If the menu has been assigned, it cannot be deleted

If the menu has been assigned, it cannot be deleted


**When deleting a menu in the project, it will prompt that there is a submenu (the menu has been assigned), and it is not allowed to delete, as follows:** ![](https://img-blog.csdnimg.cn/20201023115950263.png#pic_center ) checked the source code:
public AjaxResult remove(@PathVariable("menuId") Long menuId){
    
       
    if (menuService.selectCountMenuByParentId(menuId) > 0)    {
    
    
    return AjaxResult.warn("存在子菜单,不允许删除");  
    }   
    if (menuService.selectCountRoleMenuByMenuId(menuId) > 0)    {
    
    
    return AjaxResult.warn("菜单已分配,不允许删除");   
    }   
    return toAjax(menuService.deleteMenuById(menuId));
}

It is found that they are all related to role, how to solve this?
There is a role management module in the project, unlink the role associated with the menu to be deleted, and delete it again.
Role management is here:
insert image description here

Guess you like

Origin blog.csdn.net/weixin_44077556/article/details/109239775