|
|
@@ -34,9 +34,14 @@ public class PreviewMenuTreeService { |
|
|
|
public R treeAll(@SwParam("module") String module, UserSession us) { |
|
|
|
String prj_id = ModelProjectCache.getInstance().getIdByModule(module); |
|
|
|
if (!SwConsts.SysParam.SYS_DEBUG) { |
|
|
|
List<MenuVO> menuVOList = buildMenu(prj_id, module, us); |
|
|
|
MenuVO home = new MenuVO(); |
|
|
|
List<MenuVO> menuVOList = buildMenu(prj_id, module, us,home); |
|
|
|
if (!CommUtil.isEmpty(menuVOList)) { |
|
|
|
return R.success(menuVOList); |
|
|
|
R r = R.success(menuVOList); |
|
|
|
if(home.getId()>0){ |
|
|
|
r.put("home",home); |
|
|
|
} |
|
|
|
return r; |
|
|
|
}else { |
|
|
|
return R.success(new ArrayList<>()); |
|
|
|
} |
|
|
@@ -76,11 +81,10 @@ public class PreviewMenuTreeService { |
|
|
|
root.setPath(module); |
|
|
|
root.setId(-1L); |
|
|
|
List<MenuVO> data = TreeDataUtil.buildTree(root, list, MenuVO.createTreeHandler()); |
|
|
|
|
|
|
|
return R.success(data); |
|
|
|
return R.success(data); |
|
|
|
} |
|
|
|
|
|
|
|
public List<MenuVO> buildMenu(String prj_id, String module, UserSession us) { |
|
|
|
public List<MenuVO> buildMenu(String prj_id, String module, UserSession us,MenuVO home) { |
|
|
|
Set<MenuPlan> set = RoleHelper.getMenuPlans(us.getUserId(),us.getPartyId()); |
|
|
|
if (CommUtil.isEmpty(set)) { |
|
|
|
return new ArrayList<>(); |
|
|
@@ -89,8 +93,18 @@ public class PreviewMenuTreeService { |
|
|
|
MenuPlanContent mpc = new MenuPlanContent(menuPlan.getContent()); |
|
|
|
List<MenuVO> list = new ArrayList<>(); |
|
|
|
Set<Long> rightMenuIds = RoleHelper.getRoleMenuIds(us.getUserId() , us.getPartyId(),menuPlan.getId(), true); |
|
|
|
for(MenuPlanItem item : mpc.getHomeList()){ |
|
|
|
long id = item.getId(); |
|
|
|
if(rightMenuIds.contains(id)){ |
|
|
|
home.setId(item.getId()); |
|
|
|
home.setName(item.getLabel()); |
|
|
|
home.setIcon(item.getIcon()); |
|
|
|
home.setPath(MenuCache.getInstance().getPath(item.getMenu())); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
for (MenuPlanItem mp : mpc.getChildren(0)) { |
|
|
|
List<MenuVO> menuVOList = buildMenuWithRight(-1, mp,rightMenuIds); |
|
|
|
List<MenuVO> menuVOList = RoleHelper.isAdmin(us.getUserId())? buildMenu(-1,mp):buildMenuWithRight(-1, mp,rightMenuIds); |
|
|
|
if (menuVOList == null) continue; |
|
|
|
list.addAll(menuVOList); |
|
|
|
} |
|
|
|