应用迁移到团队应用里配置GIT

This commit is contained in:
dengqichen 2025-11-11 16:05:26 +08:00
parent 4f28a9d3e5
commit d0538de830

View File

@ -330,25 +330,36 @@ public class RepositoryProjectServiceImpl extends BaseServiceImpl<RepositoryProj
return;
}
// 1. 收集所有仓库组的 repo_group_idGit系统的组ID不是数据库主键
// 1. 收集所有仓库组的 repo_group_id external_system_id
Set<Long> repoGroupIds = projects.stream()
.map(RepositoryProjectDTO::getRepoGroupId)
.filter(id -> id != null)
.collect(Collectors.toSet());
Set<Long> externalSystemIds = projects.stream()
.map(RepositoryProjectDTO::getExternalSystemId)
.filter(id -> id != null)
.collect(Collectors.toSet());
// 2. 批量查询仓库组信息根据 repo_group_id 字段查询不是主键 id
Map<Long, RepositoryGroup> repoGroupMap = Collections.emptyMap();
// 2. 批量查询仓库组信息需要同时匹配 repo_group_id external_system_id
Map<String, RepositoryGroup> repoGroupMap = Collections.emptyMap();
if (!repoGroupIds.isEmpty()) {
List<Long> repoGroupIdList = new ArrayList<>(repoGroupIds);
// 使用复合键externalSystemId + "_" + repoGroupId 避免不同系统的 ID 冲突
repoGroupMap = repositoryGroupRepository.findByRepoGroupIdIn(repoGroupIdList).stream()
.collect(Collectors.toMap(RepositoryGroup::getRepoGroupId, Function.identity()));
.filter(group -> externalSystemIds.contains(group.getExternalSystemId()))
.collect(Collectors.toMap(
group -> group.getExternalSystemId() + "_" + group.getRepoGroupId(),
Function.identity()
));
}
// 3. 填充仓库组名称使用 repo_group_id 作为 key
Map<Long, RepositoryGroup> finalRepoGroupMap = repoGroupMap;
// 3. 填充仓库组名称使用复合键externalSystemId + "_" + repoGroupId
Map<String, RepositoryGroup> finalRepoGroupMap = repoGroupMap;
projects.forEach(project -> {
if (project.getRepoGroupId() != null) {
RepositoryGroup group = finalRepoGroupMap.get(project.getRepoGroupId());
if (project.getRepoGroupId() != null && project.getExternalSystemId() != null) {
String key = project.getExternalSystemId() + "_" + project.getRepoGroupId();
RepositoryGroup group = finalRepoGroupMap.get(key);
if (group != null) {
project.setRepoGroupName(group.getName());
}