Commit b3394d97 by zhiwj

Merge branch 'developer' of…

Merge branch 'developer' of http://115.159.76.241/base_platform_enterprise/gic-platform-enterprise into developer
parents 99840417 d0166eec
package com.gic.operation.web.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import com.gic.auth.qo.MenuOperationItemListQO;
import com.gic.open.api.dto.ServePropDTO;
......@@ -119,6 +116,11 @@ public class MenuController {
@RequestMapping("/list-menu-tree")
public RestResponse listMenuTree(MenuListQO params) {
LOGGER.info("菜单列表查询参数:{}", JSON.toJSONString(params));
int parentMenuId = MenuLevelConstants.FIRST_LEVEL_PARENT_ID;
//逐级展开的方式,所以需要传ID,如果不传,默认查询第一层级,即level = 1
if (params.getMenuId() == null) {
params.setLevel(1);
}
if (params.getIsGIC() != null && params.getIsGIC() == MenuProjectConstants.APP_PROJECT_CODE) {
//如果是查询app应用类别,必须实时更新最新应用数据
params.setNeedUpdateAppMenu(true);
......@@ -126,7 +128,7 @@ public class MenuController {
ServiceResponse<List<MenuDTO>> result = menuApiService.listMenuTree(params);
if (result.isSuccess()) {
if (StringUtils.isBlank(params.getSearch())) {
return RestResponse.success(changeListToTree(MenuLevelConstants.FIRST_LEVEL_PARENT_ID, result.getResult()));
return RestResponse.success(addAuthItemSignAndChildrenSignToList(parentMenuId, result.getResult()));
} else {
return ResultControllerUtils.commonResult(result);
}
......@@ -309,7 +311,7 @@ public class MenuController {
if (list != null) {
for (int j = 0, length = list.size(); j < length; j++) {
MenuDTO menuDTO = list.get(j);
if (storeGroupId == menuDTO.getParentId()) {
if (storeGroupId == menuDTO.getParentId() && menuDTO.getLevel() == length) {
Map<String, Object> data = new HashMap<>(16);
data.put("menuId", menuDTO.getMenuId());
data.put("menuName", menuDTO.getMenuName());
......@@ -347,6 +349,60 @@ public class MenuController {
return result;
}
/**
* 是权限项标识/是否有子菜单
* @param storeGroupId
* @param list
* @return
*/
public List<Map<String, Object>> addAuthItemSignAndChildrenSignToList(int storeGroupId, List<MenuDTO> list) {
List<Map<String, Object>> result = new ArrayList<>();
if (list != null) {
List<Integer> parentMenuIdList = new ArrayList<>(list.size());
for (MenuDTO menuDTO : list) {
parentMenuIdList.add(menuDTO.getMenuId());
}
Set<String> authItemMap = new HashSet<>(16);
Set<String> childrenMap = new HashSet<>(16);
ServiceResponse<List<MenuDTO>> listByParentIdListResult = menuApiService.listByParentMenuIdList(parentMenuIdList);
if (listByParentIdListResult.isSuccess()) {
List<MenuDTO> listByParentIdList = listByParentIdListResult.getResult();
if (CollectionUtils.isNotEmpty(listByParentIdList)) {
for (MenuDTO child : listByParentIdList) {
int menuType = child.getMenuType().intValue();
if (menuType == MenuTypeEnum.ROLE.getCode()) {
authItemMap.add(child.getParentId().toString());
} else if (menuType == MenuTypeEnum.PAGE.getCode()) {
childrenMap.add(child.getParentId().toString());
}
}
}
}
for (int j = 0, length = list.size(); j < length; j++) {
MenuDTO menuDTO = list.get(j);
if (storeGroupId == menuDTO.getParentId() && menuDTO.getLevel() == length) {
Map<String, Object> data = new HashMap<>(16);
data.put("menuId", menuDTO.getMenuId());
data.put("menuName", menuDTO.getMenuName());
data.put("menuUrl", menuDTO.getMenuUrl());
data.put("project", menuDTO.getProject());
data.put("sort", menuDTO.getSort());
data.put("menuCode", menuDTO.getMenuCode());
data.put("parentCode", menuDTO.getParentCode());
data.put("parentId", menuDTO.getParentId());
data.put("menuVersionName", menuDTO.getMenuVersionName());
data.put("seq", j + 1);
//是否拥有子集,用于 展开按钮的显示
data.put("children", childrenMap.contains(menuDTO.getMenuId().toString()));
//是否有权限项
data.put("hasAuthItem", authItemMap.contains(menuDTO.getMenuId().toString()));
result.add(data);
}
}
}
return result;
}
public static List<Map<String, Object>> changePageListToTree(int storeGroupId, List<MenuDTO> list) {
List<Map<String, Object>> result = new ArrayList<>();
if (list != null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment