/** 获取菜单名称路径(如:系统设置-机构用户-用户管理-编辑) */ public static String getMenuNamePath(String requestUri, String permission) { String href = StringUtils.substringAfter(requestUri, Global.getAdminPath()); @SuppressWarnings("unchecked") Map<String, String> menuMap = (Map<String, String>) CacheUtils.get(CACHE_MENU_NAME_PATH_MAP); if (menuMap == null) { menuMap = Maps.newHashMap(); List<Menu> menuList = menuDao.findAllList(new Menu()); for (Menu menu : menuList) { // 获取菜单名称路径(如:系统设置-机构用户-用户管理-编辑) String namePath = ""; if (menu.getParentIds() != null) { List<String> namePathList = Lists.newArrayList(); for (String id : StringUtils.split(menu.getParentIds(), ",")) { if (Menu.getRootId().equals(id)) { continue; // 过滤跟节点 } for (Menu m : menuList) { if (m.getId().equals(id)) { namePathList.add(m.getName()); break; } } } namePathList.add(menu.getName()); namePath = StringUtils.join(namePathList, "-"); } // 设置菜单名称路径 if (StringUtils.isNotBlank(menu.getHref())) { menuMap.put(menu.getHref(), namePath); } else if (StringUtils.isNotBlank(menu.getPermission())) { for (String p : StringUtils.split(menu.getPermission())) { menuMap.put(p, namePath); } } } CacheUtils.put(CACHE_MENU_NAME_PATH_MAP, menuMap); } String menuNamePath = menuMap.get(href); if (menuNamePath == null) { for (String p : StringUtils.split(permission)) { menuNamePath = menuMap.get(p); if (StringUtils.isNotBlank(menuNamePath)) { break; } } if (menuNamePath == null) { return ""; } } return menuNamePath; }