|
@@ -1,8 +1,10 @@
|
|
|
package com.dragoninfo.dcuc.auth.auth.service.impl;
|
|
|
|
|
|
import com.dragoninfo.dcuc.app.entity.ApplyInfo;
|
|
|
+import com.dragoninfo.dcuc.app.enumresources.ResourceTypeEnum;
|
|
|
import com.dragoninfo.dcuc.app.facade.IApplyInfoFacade;
|
|
|
import com.dragoninfo.dcuc.auth.auth.bpo.AppFunInfoBPO;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.dto.AppFunTreeDTO;
|
|
|
import com.dragoninfo.dcuc.auth.auth.dto.AppResourcesDto;
|
|
|
import com.dragoninfo.dcuc.auth.auth.entity.AppFunInfo;
|
|
|
import com.dragoninfo.dcuc.auth.auth.enumresources.DesignSecureTypeEnum;
|
|
@@ -64,11 +66,15 @@ public class AppFunInfoService extends BaseService<AppFunInfo, String> implement
|
|
|
*/
|
|
|
@Override
|
|
|
public List<TreeInfoVO> getMenuTreeList(String applicationId) {
|
|
|
- List<TreeInfoVO> menuInfoList = new ArrayList<TreeInfoVO>();
|
|
|
TreeInfoVO rootTreeInfo = new TreeInfoVO();//顶级节点对象
|
|
|
|
|
|
List<AppFunInfo> menuList = appFunInfoBPO.getMenuList(applicationId);
|
|
|
+ return getTreeInfoVOS(menuList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<TreeInfoVO> getTreeInfoVOS(List<AppFunInfo> menuList) {
|
|
|
if (null == menuList || menuList.size() == 0) return null;
|
|
|
+ List<TreeInfoVO> menuInfoList = new ArrayList<TreeInfoVO>();
|
|
|
String rootId = "";//顶级节点id
|
|
|
for (AppFunInfo menuInfo : menuList) {
|
|
|
TreeInfoVO treeInfoVo = new TreeInfoVO();
|
|
@@ -243,7 +249,7 @@ public class AppFunInfoService extends BaseService<AppFunInfo, String> implement
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<AppFunInfo> getbyAppIds(List<String> appIds) {
|
|
|
+ public List<AppFunInfo> getByAppIds(List<String> appIds) {
|
|
|
Searchable searchable = Searchable.newSearchable();
|
|
|
searchable.addSearchFilter("app_id",SearchOperator.in,appIds);
|
|
|
searchable.addSearchFilter("is_active",SearchOperator.eq, BooleanEnum.TRUE.getValue());
|
|
@@ -412,6 +418,106 @@ public class AppFunInfoService extends BaseService<AppFunInfo, String> implement
|
|
|
return delByAppIdAndfunCode(appFunInfo.getCode(), applyInfo.getApplyCode());
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<AppFunInfo> getByAppId(String appId) {
|
|
|
+ Searchable searchable = Searchable.newSearchable();
|
|
|
+ searchable.addSearchFilter("app_id",SearchOperator.eq,appId);
|
|
|
+ searchable.addSearchFilter("is_active",SearchOperator.eq, BooleanEnum.TRUE.getValue());
|
|
|
+ return appFunInfoBPO.find(AppFunInfo.class, searchable);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<AppFunTreeDTO> allMenuTree() {
|
|
|
+ List<AppFunInfo> allFunList = appFunInfoBPO.findAll();
|
|
|
+ Map<String, List<AppFunInfo>> funAppIdMap = allFunList.stream()
|
|
|
+ .collect(Collectors.groupingBy(AppFunInfo::getAppId));
|
|
|
+ List<String> appIds = allFunList.stream()
|
|
|
+ .map(AppFunInfo::getAppId).distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<ApplyInfo> appInfos = applyInfoFacade.getAppById(appIds);
|
|
|
+ Map<String, ApplyInfo> appInfoMap = appInfos
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.toMap(ApplyInfo::getId, item -> item, (old, last) -> last));
|
|
|
+ List<AppFunTreeDTO> trees = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, List<AppFunInfo>> entry : funAppIdMap.entrySet()) {
|
|
|
+ String appId = entry.getKey();
|
|
|
+ List<AppFunInfo> funList = entry.getValue();
|
|
|
+ Map<String, AppFunInfo> funCodeMap = funList.stream()
|
|
|
+ .collect(Collectors.toMap(AppFunInfo::getCode, item -> item, (old, last) -> last));
|
|
|
+ ApplyInfo applyInfo = appInfoMap.get(appId);
|
|
|
+ if(null == applyInfo) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ AppFunTreeDTO appNode = new AppFunTreeDTO();
|
|
|
+ appNode.setId(applyInfo.getId());
|
|
|
+ appNode.setCode(applyInfo.getApplyCode());
|
|
|
+ appNode.setLabel(applyInfo.getApplyName());
|
|
|
+ appNode.setType(ResourceTypeEnum.TJ_APP.getResourceType());
|
|
|
+ appNode.setIsTreeNode(true);
|
|
|
+ List<AppFunTreeDTO> funNodes = funList.stream().map(item -> {
|
|
|
+ AppFunTreeDTO treeDTO = new AppFunTreeDTO();
|
|
|
+ treeDTO.setId(item.getId());
|
|
|
+ treeDTO.setLabel(item.getName());
|
|
|
+ treeDTO.setCode(item.getCode());
|
|
|
+ treeDTO.setType(ResourceTypeEnum.TJ_APP_MENU.getResourceType());
|
|
|
+ String parentId = item.getParentId();
|
|
|
+ if (StringUtils.isNotBlank(parentId)) {
|
|
|
+ AppFunInfo appFunInfo = funCodeMap.get(parentId);
|
|
|
+ if (null != appFunInfo) {
|
|
|
+ treeDTO.setPid(appFunInfo.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return treeDTO;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ List<AppFunTreeDTO> appFunTreeDTOS = convertNodeToTree(funNodes);
|
|
|
+ appFunTreeDTOS.forEach(item->item.setPid(appId));
|
|
|
+ appNode.setChild(appFunTreeDTOS);
|
|
|
+ trees.add(appNode);
|
|
|
+ }
|
|
|
+ return trees;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将节点转为树结构
|
|
|
+ * @param treeNodes
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<AppFunTreeDTO> convertNodeToTree(List<AppFunTreeDTO> treeNodes) {
|
|
|
+ Map<Boolean, List<AppFunTreeDTO>> collect = treeNodes.stream()
|
|
|
+ .collect(Collectors.partitioningBy(item -> StringUtils.isBlank(item.getPid())));
|
|
|
+ List<AppFunTreeDTO> topNodes = collect.get(Boolean.TRUE);
|
|
|
+ List<AppFunTreeDTO> underNodes = collect.get(Boolean.FALSE);
|
|
|
+ Map<String, List<AppFunTreeDTO>> pidMap = underNodes.stream()
|
|
|
+ .collect(Collectors.groupingBy(AppFunTreeDTO::getPid));
|
|
|
+ innerConvertToTree(topNodes, pidMap);
|
|
|
+ return topNodes;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 递归将子节点转为树结构
|
|
|
+ * @param topNodes
|
|
|
+ * @param pidMap
|
|
|
+ */
|
|
|
+ private void innerConvertToTree(List<AppFunTreeDTO> topNodes, Map<String, List<AppFunTreeDTO>> pidMap) {
|
|
|
+ for (AppFunTreeDTO topNode : topNodes) {
|
|
|
+ String topNodeId = topNode.getId();
|
|
|
+ List<AppFunTreeDTO> childList = pidMap.get(topNodeId);
|
|
|
+ if(CollectionUtils.isNotEmpty(childList)) {
|
|
|
+ innerConvertToTree(childList, pidMap);
|
|
|
+ topNode.setChild(childList);
|
|
|
+ topNode.setIsTreeNode(true);
|
|
|
+ }else {
|
|
|
+ topNode.setIsTreeNode(false);
|
|
|
+ //前端要求放入空集合,不能是null
|
|
|
+ topNode.setChild(new ArrayList<>());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 构建服务资源数组
|
|
|
* @param inputStream
|