Commit cb02cd7c by guojuxing

菜单权限管理接口:页面、子页面

parent 5e7111a9
......@@ -51,7 +51,7 @@ public class MenuApiServiceImpl implements MenuApiService {
public ServiceResponse<List<MenuDTO>> listMenuTree(MenuListQO params) {
params.setMenuType(MenuTypeEnum.PAGE.getCode());
List<TabSysMenu> menuList = this.menuService.listMenu(params);
return ServiceResponse.success(this.treeMenu(menuList, 1, 0));
return ServiceResponse.success(EntityUtil.changeEntityListNew(MenuDTO.class, menuList));
}
@Override
......
package com.gic.auth.web.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.gic.auth.constant.MenuLevelConstants;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.MenuDTO;
......@@ -9,12 +20,7 @@ import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.response.EnterpriseRestResponse;
import com.gic.enterprise.utils.ResultControllerUtils;
import com.gic.enterprise.utils.UserDetailUtils;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import com.gic.store.dto.StoreGroupDTO;
@RestController
public class MenuController {
......@@ -95,7 +101,11 @@ public class MenuController {

 */
@RequestMapping("/list-menu-tree")
public RestResponse listMenuTree(MenuListQO params) {
return ResultControllerUtils.commonResult(menuApiService.listMenuTree(params));
ServiceResponse<List<MenuDTO>> result = menuApiService.listMenuTree(params);
if (result.isSuccess()) {
return RestResponse.success(changeListToTree(MenuLevelConstants.FIRST_LEVEL_PARENT_ID, result.getResult()));
}
return EnterpriseRestResponse.failure(result);
}
/**
* 查询页面下面的权限项列表数据
......@@ -109,4 +119,30 @@ public class MenuController {
public RestResponse listMenuRole(Integer parentId) {
return ResultControllerUtils.commonResult(menuApiService.listMenuRoleByParentId(parentId));
}
public static List<Map<String, Object>> changeListToTree(int storeGroupId, List<MenuDTO> list) {
List<Map<String, Object>> result = new ArrayList<>();
if (list != null) {
for (MenuDTO menuDTO : list) {
if (storeGroupId == menuDTO.getParentId() && menuDTO.getIsShow().intValue() == 1) {
Map<String, Object> data = new HashMap<>(16);
data.put("menuId", menuDTO.getMenuId());
data.put("menuName", menuDTO.getMenuName());
data.put("project", menuDTO.getProject());
data.put("sort", menuDTO.getSort());
data.put("menuCode", menuDTO.getMenuCode());
data.put("parentCode", menuDTO.getParentCode());
data.put("menuVersion", menuDTO.getMenuVersion());
List<Map<String, Object>> children = changeListToTree(menuDTO.getMenuId(), list);
if (children == null || children.size() < 1) {
data.put("children", null);
} else {
data.put("children", children);
}
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