liyongbin 2023-12-26 22:30:47 +08:00
parent ac452af8ed
commit 366402eb13
1 changed files with 7 additions and 3 deletions

View File

@ -97,14 +97,18 @@ public class ApiGroupServiceImpl extends BaseServiceImpl<ApiGroupDao, ApiGroupEn
* @param path
* @return
*/
//1
private String recursionPath(ApiGroupEntity groupEntity, String path) {
if (StringUtil.isBlank(path)) {
// 如果路径为空,则将路径设置为组实体的名称
path = groupEntity.getName();
}
if (groupEntity.getParentId() != 0) {
ApiGroupEntity parent = getById(groupEntity.getParentId());
path = parent.getName() + "/" + path;
return recursionPath(parent, path);
// 如果组实体的父ID不为0
// 查询父级组实体
ApiGroupEntity parent = getById(groupEntity.getParentId()); // 通过父ID获取父级组实体
path = parent.getName() + "/" + path; // 将父级组实体的名称与当前路径拼接起来,中间以斜杠分隔
return recursionPath(parent, path); // 递归调用recursionPath方法传入父级组实体和拼接后的路径
}
return path;
}