|
@@ -7,7 +7,6 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.tr.core.exception.ServiceException;
|
|
import cn.tr.core.exception.ServiceException;
|
|
|
import cn.tr.core.exception.TRExcCode;
|
|
import cn.tr.core.exception.TRExcCode;
|
|
|
-import cn.tr.core.tree.TreeNode;
|
|
|
|
|
import cn.tr.core.utils.MenuUtil;
|
|
import cn.tr.core.utils.MenuUtil;
|
|
|
import cn.tr.core.utils.TreeUtil;
|
|
import cn.tr.core.utils.TreeUtil;
|
|
|
import cn.tr.module.api.sys.user.CbbMenuDTO;
|
|
import cn.tr.module.api.sys.user.CbbMenuDTO;
|
|
@@ -26,7 +25,9 @@ import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
import javax.annotation.PostConstruct;
|
|
|
|
|
+import java.io.File;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -60,7 +61,9 @@ public class SysMenuApiProvider implements SysMenuApi {
|
|
|
List<RouteItemVO> routeItemVOS = TreeUtil.buildTree(currentUserService.currentUserMenus(""));
|
|
List<RouteItemVO> routeItemVOS = TreeUtil.buildTree(currentUserService.currentUserMenus(""));
|
|
|
return routeItemVOS.stream()
|
|
return routeItemVOS.stream()
|
|
|
.findFirst()
|
|
.findFirst()
|
|
|
- .map(this::recursionRoute)
|
|
|
|
|
|
|
+ .map(item->{
|
|
|
|
|
+ return recursionRoute(item,"");
|
|
|
|
|
+ })
|
|
|
.orElse("");
|
|
.orElse("");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -188,20 +191,38 @@ public class SysMenuApiProvider implements SysMenuApi {
|
|
|
* @author wangzl
|
|
* @author wangzl
|
|
|
* @date 2025/9/28
|
|
* @date 2025/9/28
|
|
|
*/
|
|
*/
|
|
|
- private String recursionRoute(RouteItemVO routeItemVO){
|
|
|
|
|
- if(routeItemVO==null){
|
|
|
|
|
|
|
+ private String recursionRoute(RouteItemVO routeItemVO, String parentPath) {
|
|
|
|
|
+ if (routeItemVO == null) {
|
|
|
return "";
|
|
return "";
|
|
|
}
|
|
}
|
|
|
- if(CollectionUtil.isEmpty(routeItemVO.getChildren())){
|
|
|
|
|
- return routeItemVO.getName();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ String currentName = routeItemVO.getName();
|
|
|
|
|
+ if (currentName == null) {
|
|
|
|
|
+ currentName = "";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- RouteItemVO firstChild = (RouteItemVO) routeItemVO.getChildren().stream()
|
|
|
|
|
- .findFirst()
|
|
|
|
|
- .orElse(null);
|
|
|
|
|
|
|
+ // 构建当前路径
|
|
|
|
|
+ String currentPath;
|
|
|
|
|
+ if (StrUtil.isNotBlank(parentPath)) {
|
|
|
|
|
+ currentPath = parentPath + "/" + currentName;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ currentPath = currentName;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return recursionRoute(firstChild);
|
|
|
|
|
|
|
+ // 检查子节点集合是否为空
|
|
|
|
|
+ if (CollectionUtil.isEmpty(routeItemVO.getChildren())) {
|
|
|
|
|
+ return currentPath;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ // 获取第一个子节点,避免类型转换风险
|
|
|
|
|
+ Object firstChildObj = routeItemVO.getChildren().iterator().next();
|
|
|
|
|
+ if (firstChildObj instanceof RouteItemVO) {
|
|
|
|
|
+ RouteItemVO firstChild = (RouteItemVO) firstChildObj;
|
|
|
|
|
+ return recursionRoute(firstChild, currentPath);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return currentPath;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|