List<SuperMenu> superList=new ArrayList<SuperMenu>();
//取得所有显示为菜单的功能
List<Map<String, Object>> authorList = service.getfindAll();
List<String> superNameList = new ArrayList<String>();
Map<String,List<Menu>> menuMap = new HashMap<String, List<Menu>>();
List<Menu> menuList = new ArrayList<Menu>();
for(Map<String,Object> map:authorList){
if(StringUtils.isNullOrEmpty(String.valueOf(map.get("functiomParentId")))){
//取得父级菜单
List<Object> params=new ArrayList<Object>();
params.add(Long.valueOf(String.valueOf(map.get("functionId"))));
Map<String,Object> m=service.getfindMenu(params);
if(menuMap.get(m.get("functionName")) == null){
menuList = new ArrayList<Menu>();
superNameList.add(String.valueOf(m.get("functionId")));
superNameList.add(String.valueOf(m.get("functionName")));
}
params=new ArrayList<Object>();
params.add(Long.valueOf(String.valueOf(m.get("functionId"))));
List<Map<String, Object>> childList =service.getfindChild(params);//查询子级
for(Map<String,Object> fc:childList){
Menu menu = new Menu();
menu.setFunctionPath(String.valueOf(fc.get("functionPath")));
menu.setFunName(String.valueOf(fc.get("functionName")));
menuList.add(menu);
}
if(!menuMap.containsKey(String.valueOf(m.get("functionName")))){
menuMap.put(String.valueOf(m.get("functionName")), menuList);
}
}else{
continue;
}
}
superList = new ArrayList<SuperMenu>();
for(int i=0;i<superNameList.size();i++){
String supid= superNameList.get(i);
String superName = superNameList.get(i+1);
SuperMenu superMenu = new SuperMenu();
superMenu.setPid(Long.valueOf(supid));
superMenu.setFunName(superName);
superMenu.setMenuList(menuMap.get(superName));
superList.add(superMenu);
i=i+1;
}
request.setAttribute("superList",superList);
request.getRequestDispatcher("center.jsp").forward(request, response);