/** * isShowHide是否显示隐藏菜单 * * @param extId * @param isShowHidden * @param response * @return */ @RequiresPermissions("user") @ResponseBody @RequestMapping(value = "treeData") public List<Map<String, Object>> treeData( @RequestParam(required = false) String extId, @RequestParam(required = false) String isShowHide, HttpServletResponse response) { List<Map<String, Object>> mapList = Lists.newArrayList(); List<Menu> list = systemService.findAllMenu(); for (int i = 0; i < list.size(); i++) { Menu e = list.get(i); if (StringUtils.isBlank(extId) || (extId != null && !extId.equals(e.getId()) && e.getParentIds().indexOf("," + extId + ",") == -1)) { if (isShowHide != null && isShowHide.equals("0") && e.getIsShow().equals("0")) { continue; } Map<String, Object> map = Maps.newHashMap(); map.put("id", e.getId()); map.put("pId", e.getParentId()); map.put("name", e.getName()); mapList.add(map); } } return mapList; }
@RequiresPermissions("sys:menu:view") @RequestMapping(value = "form") public String form(Menu menu, Model model) { if (menu.getParent() == null || menu.getParent().getId() == null) { menu.setParent(new Menu(Menu.getRootId())); } menu.setParent(systemService.getMenu(menu.getParent().getId())); // 获取排序号,最末节点排序号+30 if (StringUtils.isBlank(menu.getId())) { List<Menu> list = Lists.newArrayList(); List<Menu> sourcelist = systemService.findAllMenu(); Menu.sortList(list, sourcelist, menu.getParentId(), false); if (list.size() > 0) { menu.setSort(list.get(list.size() - 1).getSort() + 30); } } model.addAttribute("menu", menu); return "modules/sys/menuForm"; }