@Test public void getMenuRouter() { List<MenuRouter> menuRouters = menuService.getMenuRouter(new HashSet<>()); System.out.printf(">>" + JsonUtils.toJsonString(menuRouters)); }
@Override public List<MenuRouter> getMenuRouter(Set<String> roles) { List<MenuRouter> menuRouters = new ArrayList<>(); List<Menu> menus = menuRepository.findMenuByRoles(roles); List<MenuRouter> routers = getTreeNodeList(menus); Map<Long, MenuRouter> menuMap = getTreeNodeMap(routers); routers.stream().forEach(router -> { if (menuMap.containsKey(router.getPid())) { MenuRouter parentRouter = menuMap.get(router.getPid()); parentRouter.setAlwaysShow(true); parentRouter.getChildren().add(router); } else { menuRouters.add(router); } }); return menuRouters; }
MenuServiceImpl extends AbstractService<Menu, Long> implements MenuService { @Override public List<MenuRouter> getMenuRouter(Set<String> roles) { List<MenuRouter> menuRouters = new ArrayList<>(); List<Menu> menus = menuRepository.findMenuByRoles(roles); List<MenuRouter> routers = getTreeNodeList(menus); Map<Long, MenuRouter> menuMap = getTreeNodeMap(routers); routers.stream().forEach(router -> { if (menuMap.containsKey(router.getPid())) { MenuRouter parentRouter = menuMap.get(router.getPid()); parentRouter.setAlwaysShow(true); parentRouter.getChildren().add(router); } else { menuRouters.add(router); } }); return menuRouters; } }
MenuServiceImpl extends AbstractService<Menu, Long> implements MenuService { @Override public List<MenuRouter> getMenuRouter(Set<String> roles) { List<MenuRouter> menuRouters = new ArrayList<>(); List<Menu> menus = menuRepository.findMenuByRoles(roles); List<MenuRouter> routers = getTreeNodeList(menus); Map<Long, MenuRouter> menuMap = getTreeNodeMap(routers); routers.stream().forEach(router -> { if (menuMap.containsKey(router.getPid())) { MenuRouter parentRouter = menuMap.get(router.getPid()); parentRouter.setAlwaysShow(true); parentRouter.getChildren().add(router); } else { menuRouters.add(router); } }); return menuRouters; }  }
MenuServiceImpl extends AbstractService<Menu, Long> implements MenuService { @Override public List<MenuRouter> getMenuRouter(Set<String> roles) { List<MenuRouter> menuRouters = new ArrayList<>(); List<Menu> menus = menuRepository.findMenuByRoles(roles); List<MenuRouter> routers = getTreeNodeList(menus); Map<Long, MenuRouter> menuMap = getTreeNodeMap(routers); routers.stream().forEach(router -> { if (menuMap.containsKey(router.getPid())) { MenuRouter parentRouter = menuMap.get(router.getPid()); parentRouter.setAlwaysShow(true); parentRouter.getChildren().add(router); } else { menuRouters.add(router); } }); return menuRouters; }  @Override List<MenuTree> getMenuTree(Long pid); @Override List<MenuRouter> getMenuRouter(Set<String> roles); @Override List<MenuResponse> getMenus(); @Override void delete(Set<Long> ids); @Override boolean update(Menu obj); }
MenuServiceImpl extends AbstractService<Menu, Long> implements MenuService { @Override public List<MenuRouter> getMenuRouter(Set<String> roles) { List<MenuRouter> menuRouters = new ArrayList<>(); List<Menu> menus = menuRepository.findMenuByRoles(roles); List<MenuRouter> routers = getTreeNodeList(menus); Map<Long, MenuRouter> menuMap = getTreeNodeMap(routers); routers.stream().forEach(router -> { if (menuMap.containsKey(router.getPid())) { MenuRouter parentRouter = menuMap.get(router.getPid()); parentRouter.setAlwaysShow(true); parentRouter.getChildren().add(router); } else { menuRouters.add(router); } }); return menuRouters; }  @Override List<MenuTree> getMenuTree(Long pid); @Override List<MenuRouter> getMenuRouter(Set<String> roles); @Override List<MenuResponse> getMenus(); @Override void delete(Set<Long> ids); @Override boolean update(Menu obj);  }