|
@@ -1,5 +1,6 @@
|
|
|
package com.dragoninfo.dcuc.auth.auth.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.dragoninfo.dcuc.app.entity.ApplyInfo;
|
|
|
import com.dragoninfo.dcuc.app.enumresources.ResourceTypeEnum;
|
|
|
import com.dragoninfo.dcuc.app.facade.IApplyInfoFacade;
|
|
@@ -15,7 +16,9 @@ import com.dragoninfo.dcuc.auth.auth.service.IStaffAssignAuthInfoService;
|
|
|
import com.dragoninfo.dcuc.auth.auth.vo.AppFunInfoVo;
|
|
|
import com.dragoninfo.dcuc.auth.auth.vo.AppFunVO;
|
|
|
import com.dragoninfo.dcuc.auth.auth.vo.TreeInfoVO;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.vo.appfun.RespAppFunTreeVo;
|
|
|
import com.dragoninfo.dcuc.auth.util.TreeUtil;
|
|
|
+import com.dragoninfo.dcuc.common.utils.DcucBeanUtil;
|
|
|
import com.dragoninfo.dcuc.duceap.enums.FunUsageScenariosEnum;
|
|
|
import com.dragoninfo.dcuc.duceap.facade.IDuceapUploadFacade;
|
|
|
import com.dragoninfo.dcuc.duceap.upload.dto.DocContentDTO;
|
|
@@ -58,7 +61,9 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
@Transactional
|
|
|
public class AppFunInfoService implements IAppFunInfoService {
|
|
|
+
|
|
|
private Logger logger = LoggerFactory.getLogger(AppFunInfoService.class);
|
|
|
+
|
|
|
@Autowired
|
|
|
private AppFunInfoBPO appFunInfoBPO;
|
|
|
|
|
@@ -511,7 +516,7 @@ public class AppFunInfoService implements IAppFunInfoService {
|
|
|
}
|
|
|
List<AppFunInfo> funInfos = getByAppId(appFunInfo.getAppId());
|
|
|
Set<String> delIds = getDelIds(appFunInfo, funInfos);
|
|
|
- if(!delIds.isEmpty()) {
|
|
|
+ if (!delIds.isEmpty()) {
|
|
|
appFunInfoBPO.batchDelete(delIds.toArray(new String[0]));
|
|
|
}
|
|
|
return ResponseStatus.success("删除成功");
|
|
@@ -524,12 +529,12 @@ public class AppFunInfoService implements IAppFunInfoService {
|
|
|
upCodes.add(delMenu.getCode());
|
|
|
//找到所有子节点id
|
|
|
Map<String, List<AppFunInfo>> collect = allMenus.stream()
|
|
|
- .filter(e->StringUtils.isNotBlank(e.getParentId()))
|
|
|
+ .filter(e -> StringUtils.isNotBlank(e.getParentId()))
|
|
|
.collect(Collectors.groupingBy(AppFunInfo::getParentId));
|
|
|
- while (upCodes.size()>0) {
|
|
|
+ while (upCodes.size() > 0) {
|
|
|
for (String upCode : upCodes) {
|
|
|
List<AppFunInfo> child = collect.get(upCode);
|
|
|
- if(CollectionUtils.isNotEmpty(child)) {
|
|
|
+ if (CollectionUtils.isNotEmpty(child)) {
|
|
|
Set<String> childSet = child.stream()
|
|
|
.map(AppFunInfo::getCode)
|
|
|
.collect(Collectors.toSet());
|
|
@@ -599,11 +604,11 @@ public class AppFunInfoService implements IAppFunInfoService {
|
|
|
String userId = ContextUtils.getUserInfo().getId();
|
|
|
|
|
|
List<String> roleIds = staffAssignAuthInfoService.getAllRoleIds(userId);
|
|
|
- if(CollectionUtils.isEmpty(roleIds)) {
|
|
|
+ if (CollectionUtils.isEmpty(roleIds)) {
|
|
|
return funAppIdMap;
|
|
|
}
|
|
|
List<String> existFunIds = rsRlService.getFunIdsByRoleIds(roleIds);
|
|
|
- if(CollectionUtils.isEmpty(existFunIds)) {
|
|
|
+ if (CollectionUtils.isEmpty(existFunIds)) {
|
|
|
return funAppIdMap;
|
|
|
}
|
|
|
|
|
@@ -706,6 +711,71 @@ public class AppFunInfoService implements IAppFunInfoService {
|
|
|
return appFunInfoBPO.count(startTime, endTime);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<RespAppFunTreeVo> getRoleMenuTree(String roleId) {
|
|
|
+ List<AppFunInfo> funInfos = appFunInfoBPO.getByRoleId(roleId);
|
|
|
+ List<RespAppFunTreeVo> list = funInfos.stream()
|
|
|
+ .filter(e -> BooleanEnum.TRUE.value.equals(e.getIsActive()))
|
|
|
+ .map(e -> {
|
|
|
+ RespAppFunTreeVo vo = new RespAppFunTreeVo();
|
|
|
+ BeanUtils.copyProperties(e, vo);
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return constructToTree(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 组装成树节点
|
|
|
+ *
|
|
|
+ * @param funInfos
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<RespAppFunTreeVo> constructToTree(List<RespAppFunTreeVo> funInfos) {
|
|
|
+ if (CollectionUtils.isEmpty(funInfos)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ //去除pid数据错误问题。由功能菜单保存和修改引起
|
|
|
+ //如果pid在所有code中不存在,将pid设置为null
|
|
|
+ Set<String> allIdSet = funInfos.stream().map(RespAppFunTreeVo::getId).collect(Collectors.toSet());
|
|
|
+ funInfos.stream().filter(e -> {
|
|
|
+ String parentId = e.getParentId();
|
|
|
+ if (null != parentId && !allIdSet.contains(parentId)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }).forEach(e -> e.setParentId(null));
|
|
|
+ //将顶级节点和子节点分组
|
|
|
+ Map<Boolean, List<RespAppFunTreeVo>> collect = funInfos.stream()
|
|
|
+ .collect(Collectors.partitioningBy(e -> StrUtil.isBlank(e.getParentId())));
|
|
|
+ //所有顶级节点
|
|
|
+ List<RespAppFunTreeVo> topNode = collect.get(Boolean.TRUE);
|
|
|
+ //所有子节点
|
|
|
+ List<RespAppFunTreeVo> childes = collect.get(Boolean.FALSE);
|
|
|
+
|
|
|
+ //所有分组后的子节点
|
|
|
+ //将子节点按pid再分组
|
|
|
+ //分组后转为RespFuncAuthenApiVo对象
|
|
|
+ Map<String, List<RespAppFunTreeVo>> groupMap = childes.stream()
|
|
|
+ .collect(Collectors.groupingBy(RespAppFunTreeVo::getParentId));
|
|
|
+
|
|
|
+ //组装成树节点
|
|
|
+ Deque<RespAppFunTreeVo> deque = new LinkedList<>(topNode);
|
|
|
+ while (!deque.isEmpty()) {
|
|
|
+ RespAppFunTreeVo first = deque.pollFirst();
|
|
|
+ String pid = first.getId();
|
|
|
+ List<RespAppFunTreeVo> child = groupMap.get(pid);
|
|
|
+ if (CollectionUtils.isEmpty(child)) {
|
|
|
+ first.setChildren(Collections.emptyList());
|
|
|
+ first.setIsParent(false);
|
|
|
+ } else {
|
|
|
+ first.setChildren(child);
|
|
|
+ first.setIsParent(true);
|
|
|
+ deque.addAll(child);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return topNode;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取需要的功能和菜单
|
|
|
* 尽量不使用递归,整个应用和菜单 栈深度太深
|
|
@@ -751,7 +821,7 @@ public class AppFunInfoService implements IAppFunInfoService {
|
|
|
if (null == appFunInfo) {
|
|
|
continue;
|
|
|
}
|
|
|
- if(addedCode.contains(code)) {
|
|
|
+ if (addedCode.contains(code)) {
|
|
|
continue;
|
|
|
}
|
|
|
String pCode = appFunInfo.getParentId();
|