{"record":{"id":"9f22c550a79df6b5","repo":"paascloud/paascloud-master","slug":"uac10013007","errorCode":"UAC10013007","errorMessage":"根菜单不能禁用","messagePattern":"根菜单不能禁用","errorType":"error_code","errorClass":"UacBizException","httpStatus":null,"severity":"warning","filePath":"paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacMenuServiceImpl.java","lineNumber":335,"sourceCode":"\t\tViewMenuVo menuVo = modelMapper.map(menu, ViewMenuVo.class);\n\n\t\tif (parentMenu != null) {\n\t\t\tmenuVo.setParentMenuName(parentMenu.getMenuName());\n\t\t}\n\n\t\treturn menuVo;\n\t}\n\n\t@Override\n\tpublic void updateUacMenuStatusById(UacMenuStatusDto uacMenuStatusDto, LoginAuthDto loginAuthDto) {\n\t\tLong id = uacMenuStatusDto.getId();\n\t\tString status = uacMenuStatusDto.getStatus();\n\t\tPreconditions.checkArgument(id != null, \"菜单ID不能为空\");\n\t\tPreconditions.checkArgument(StringUtils.isNotEmpty(status), \"菜单状态不能为空\");\n\n\t\tUacMenu uacMenuQuery = this.selectByKey(id);\n\t\tif (MenuConstant.MENU_LEVEL_ROOT.equals(uacMenuQuery.getLevel())) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10013007);\n\t\t}\n\t\t// 要处理的菜单集合\n\t\tList<UacMenu> menuList = Lists.newArrayList();\n\n\t\tint result;\n\t\tif (status.equals(UacMenuStatusEnum.DISABLE.getType())) {\n\t\t\t// 获取菜单以及子菜单\n\t\t\tmenuList = this.getAllChildMenuByMenuId(id, UacMenuStatusEnum.ENABLE.getType());\n\t\t\t// 禁用菜单以及子菜单\n\t\t\tresult = this.disableMenuList(menuList, loginAuthDto);\n\t\t} else {\n\t\t\t// 获取菜单、其子菜单以及父菜单\n\t\t\tUacMenu uacMenu = new UacMenu();\n\t\t\tuacMenu.setPid(id);\n\t\t\tresult = this.selectCount(uacMenu);\n\t\t\t// 此菜单含有子菜单\n\t\t\tif (result > 0) {\n\t\t\t\tmenuList = this.getAllChildMenuByMenuId(id, UacMenuStatusEnum.DISABLE.getType());","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacMenuServiceImpl.java#L317-L353","documentation":"UacBizException UAC10013007 thrown by updateUacMenuStatusById when attempting to change the status of the root menu. The service loads the menu by id and, if its level equals MenuConstant.MENU_LEVEL_ROOT, refuses the operation because the root menu must always remain enabled. Message: '根菜单不能禁用' (root menu cannot be disabled).","triggerScenarios":"Calling updateUacMenuStatusById(id, status) where the id refers to the root-level menu (level == MENU_LEVEL_ROOT), regardless of whether the requested status is ENABLE or DISABLE.","commonSituations":"UI exposing a disable/enable toggle on the root menu row by mistake; API-level scripts iterating all menus and toggling status without excluding the root; seed/migration data with an unexpected root-level menu id.","solutions":["Exclude the root menu (level == MENU_LEVEL_ROOT) from status-change operations in the caller.","Hide the status toggle in the UI for rows whose level is root.","If this is not meant to be the root, verify the menuId — you are likely passing the wrong id.","Check uac_menu.level for the row with that id to confirm which menu you are targeting."],"exampleFix":"// before: allow any menu to be status-toggled\nmenuList.forEach(m -> uacMenuService.updateUacMenuStatusById(m.getId(), status));\n// after: skip the root menu\nif (MenuConstant.MENU_LEVEL_ROOT.equals(menu.getLevel())) {\n  return; // root cannot be disabled\n}\nuacMenuService.updateUacMenuStatusById(menu.getId(), status);","handlingStrategy":"validation","validationCode":"UacMenu menu = uacMenuService.selectByKey(id);\nif (menu != null && MenuConstant.MENU_LEVEL_ROOT.equals(menu.getLevel())) {\n  // skip or reject: root menu status cannot be changed\n}","typeGuard":"boolean isRootMenu(UacMenu menu) { return menu != null && MenuConstant.MENU_LEVEL_ROOT.equals(menu.getLevel()); }","tryCatchPattern":"try {\n  uacMenuService.updateUacMenuStatusById(statusDto, loginAuthDto);\n} catch (UacBizException e) {\n  if (\"UAC10013007\".equals(e.getCode())) { /* notify: root menu cannot be disabled */ }\n  throw e;\n}","preventionTips":["Hide status toggles for root-level rows in the admin UI.","Filter out root menus from bulk status-change scripts.","Load the menu's level before issuing any status update."],"tags":["menu-management","uac","business-rule","root-menu"],"backgroundTag":"unsupported-operation","analyzedSha":"781281a9503332ed3cef44ea618349d14230a127","analyzedAt":"2026-09-10T10:59:02.070Z","contentChangedAt":"2026-09-10T10:59:02.070Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}