|
@@ -8,9 +8,12 @@ import com.dragoninfo.dcuc.auth.auth.dto.AppResourcesDto;
|
|
|
import com.dragoninfo.dcuc.auth.auth.dto.RoleApiDto;
|
|
|
import com.dragoninfo.dcuc.auth.auth.facade.IFunAuthResultFacade;
|
|
|
import com.dragoninfo.dcuc.auth.auth.facade.IRoleFacade;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.vo.AppFunInfoVo;
|
|
|
import com.dragoninfo.dcuc.auth.auth.vo.AppFunVO;
|
|
|
import com.dragoninfo.dcuc.auth.power.facade.IAppFunInfoFacade;
|
|
|
import com.dragoninfo.dcuc.authweb.restcontroller.api.authservice.v3.vo.AppFunAuthApiVo;
|
|
|
+import com.dragoninfo.dcuc.authweb.restcontroller.api.authservice.v3.vo.AppFunInfoApiVo;
|
|
|
+import com.dragoninfo.dcuc.authweb.restcontroller.api.authservice.v3.vo.FunCodeTreeApiVo;
|
|
|
import com.dragoninfo.dcuc.authweb.util.VersionUtils;
|
|
|
import com.dragoninfo.dcuc.authweb.vo.AuthManagerRes;
|
|
|
import com.dragoninfo.dcuc.authweb.vo.AuthResourceVo;
|
|
@@ -142,17 +145,21 @@ public class AuthV3ApiController {
|
|
|
roleApiDto.setAppCode(managerRes.getAppCode());
|
|
|
roleApiDto.setUserId(userInfo.getId());
|
|
|
roleApiDto.setIdcard(managerRes.getIdcard());
|
|
|
- List<Map<String, Object>> list = roleFacade.getMenus(roleApiDto);
|
|
|
-
|
|
|
- //去重
|
|
|
- Set<Map<String, Object>> result = new HashSet<>(list);
|
|
|
- List<Map<String, Object>> mapList = this.addMap(new ArrayList<>(result), null);
|
|
|
- List<AppFunAuthApiVo> roleResult = mapList.stream().map(item -> {
|
|
|
- String str = JSON.toJSONString(item);
|
|
|
- AppFunAuthApiVo apiVo = JSON.parseObject(str, AppFunAuthApiVo.class);
|
|
|
- return apiVo;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- return ApiResult.setSuccessResult(roleResult);
|
|
|
+ List<AppFunInfoDTO> menus = roleFacade.getMenus(roleApiDto);
|
|
|
+ List<AppFunInfoApiVo> vos = Optional.ofNullable(menus)
|
|
|
+ .orElse(new ArrayList<>())
|
|
|
+ .stream()
|
|
|
+ .map(item -> {
|
|
|
+ AppFunInfoApiVo vo = new AppFunInfoApiVo();
|
|
|
+ vo.setName(item.getName());
|
|
|
+ vo.setCode(item.getCode());
|
|
|
+ vo.setPid(item.getParentId());
|
|
|
+ vo.setUrl(item.getUrl());
|
|
|
+ vo.setSort(item.getSeq());
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ List<FunCodeTreeApiVo> mapList = constructFunCodeTree(vos, null);
|
|
|
+ return ApiResult.setSuccessResult(mapList);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -163,14 +170,14 @@ public class AuthV3ApiController {
|
|
|
* @param pid 父节点
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<Map<String, Object>> addMap(List<Map<String, Object>> maps, String pid) {
|
|
|
- List<Map<String, Object>> mapList = new ArrayList<>();
|
|
|
+ private List<FunCodeTreeApiVo> constructFunCodeTree (List<AppFunInfoApiVo> maps, String pid) {
|
|
|
+ List<FunCodeTreeApiVo> mapList = new ArrayList<>();
|
|
|
maps.forEach(item -> {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- if (item.get("pid") == null || StringUtils.isEmpty((String) item.get("pid"))) {
|
|
|
- map.put("code", item.get("code"));
|
|
|
- map.put("nextNode", getChildren(maps, (String) item.get("code")));
|
|
|
- mapList.add(map);
|
|
|
+ FunCodeTreeApiVo vo = new FunCodeTreeApiVo();
|
|
|
+ if (item.getPid() == null || StringUtils.isEmpty(item.getPid())) {
|
|
|
+ vo.setCode(item.getCode());
|
|
|
+ vo.setNextNode(getChildren(maps,item.getCode()));
|
|
|
+ mapList.add(vo);
|
|
|
}
|
|
|
|
|
|
});
|
|
@@ -184,14 +191,14 @@ public class AuthV3ApiController {
|
|
|
* @param pid 父节点
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<Map<String, Object>> getChildren(List<Map<String, Object>> maps, String pid) {
|
|
|
- List<Map<String, Object>> mapList = new ArrayList<>();
|
|
|
+ private List<FunCodeTreeApiVo> getChildren(List<AppFunInfoApiVo> maps, String pid) {
|
|
|
+ List<FunCodeTreeApiVo> mapList = new ArrayList<>();
|
|
|
maps.forEach(item -> {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- if (pid.equals(item.get("pid"))) {
|
|
|
- map.put("code", item.get("code"));
|
|
|
- map.put("nextNode", getChildren(maps, (String) item.get("code")));
|
|
|
- mapList.add(map);
|
|
|
+ FunCodeTreeApiVo vo = new FunCodeTreeApiVo();
|
|
|
+ if (pid.equals(item.getPid())) {
|
|
|
+ vo.setCode(item.getCode());
|
|
|
+ vo.setNextNode(getChildren(maps, item.getCode()));
|
|
|
+ mapList.add(vo);
|
|
|
}
|
|
|
});
|
|
|
return mapList;
|