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