Commit 94281b70 by guojuxing

权限菜单查询方式调整:一开始只查询第一层

parent b3394d97
......@@ -116,7 +116,6 @@ 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);
......@@ -128,7 +127,7 @@ public class MenuController {
ServiceResponse<List<MenuDTO>> result = menuApiService.listMenuTree(params);
if (result.isSuccess()) {
if (StringUtils.isBlank(params.getSearch())) {
return RestResponse.success(addAuthItemSignAndChildrenSignToList(parentMenuId, result.getResult()));
return RestResponse.success(addAuthItemSignAndChildrenSignToList(result.getResult()));
} else {
return ResultControllerUtils.commonResult(result);
}
......@@ -311,7 +310,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() && menuDTO.getLevel() == length) {
if (storeGroupId == menuDTO.getParentId()) {
Map<String, Object> data = new HashMap<>(16);
data.put("menuId", menuDTO.getMenuId());
data.put("menuName", menuDTO.getMenuName());
......@@ -351,11 +350,10 @@ public class MenuController {
/**
* 是权限项标识/是否有子菜单
* @param storeGroupId
* @param list
* @return
*/
public List<Map<String, Object>> addAuthItemSignAndChildrenSignToList(int storeGroupId, List<MenuDTO> list) {
public List<Map<String, Object>> addAuthItemSignAndChildrenSignToList(List<MenuDTO> list) {
List<Map<String, Object>> result = new ArrayList<>();
if (list != null) {
List<Integer> parentMenuIdList = new ArrayList<>(list.size());
......@@ -380,24 +378,22 @@ public class MenuController {
}
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);
}
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;
......
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