Merge pull request 'feat(超算专区): 获取项目聚合列表时,若项目为镜像项目则返回项目的镜像owner' (#1099) from otto/microservices:chaosuan_zone into chaosuan_zone

This commit is contained in:
otto 2026-04-29 11:23:07 +08:00
commit 1ea5e87767
1 changed files with 23 additions and 0 deletions

View File

@ -214,6 +214,24 @@ public class ZoneProjectServiceImpl implements IZoneProjectService {
}
}
private static String extractFirstPathSegment(String url) {
if (url == null || url.isEmpty()) return null;
// 找到协议后的第一个 '/' 的位置路径开始
int schemeSep = url.indexOf("://");
if (schemeSep == -1) return null;
int hostStart = schemeSep + 3;
int pathStart = url.indexOf('/', hostStart);
if (pathStart == -1) return null; // 没有路径
// 找到下一个 '/' 或结尾
int pathEnd = url.indexOf('/', pathStart + 1);
if (pathEnd == -1) pathEnd = url.length();
return url.substring(pathStart + 1, pathEnd);
}
private ZoneProjectDataVo zoneProjectToZoneProjectDataVo(ZoneProject zoneProject, JSONObject gitLinkProject) {
//每次从GitLink查询项目时自动更新项目名称和项目标识
updateProjectNameAndFullName(gitLinkProject, zoneProject);
@ -233,6 +251,11 @@ public class ZoneProjectServiceImpl implements IZoneProjectService {
projectKeyName.put("name", "项目名称");
projectPropertiesVo.put("fullName", author.getString("login") + "/" + gitLinkProject.getString("identifier"));
projectKeyName.put("fullName", "项目完整地址");
projectPropertiesVo.put("fromOwner", author.getString("login"));
}
String mirrorUrl = gitLinkProject.getString("mirror_url");
if (StringUtils.isNotEmpty(mirrorUrl)) {
projectPropertiesVo.put("fromOwner", extractFirstPathSegment(mirrorUrl));
}
String description = gitLinkProject.getString("description");
projectPropertiesVo.put("description", description);