打印了JENKINS节点日志
This commit is contained in:
parent
af95532706
commit
e8f6102067
@ -35,6 +35,8 @@ public class RepositoryProjectDTO extends BaseDTO {
|
||||
|
||||
private Long repoGroupId;
|
||||
|
||||
private String repoGroupName;
|
||||
|
||||
private Long repoProjectId;
|
||||
|
||||
/**
|
||||
|
||||
@ -304,17 +304,54 @@ public class RepositoryProjectServiceImpl extends BaseServiceImpl<RepositoryProj
|
||||
@Override
|
||||
public Page<RepositoryProjectDTO> page(RepositoryProjectQuery query) {
|
||||
Page<RepositoryProjectDTO> page = super.page(query);
|
||||
fillBranchCounts(page.getContent());
|
||||
return page;
|
||||
fillExtendedFields(page.getContent());
|
||||
return new PageImpl<>(page.getContent(), page.getPageable(), page.getTotalElements());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RepositoryProjectDTO> findAll(RepositoryProjectQuery query) {
|
||||
List<RepositoryProjectDTO> list = super.findAll(query);
|
||||
fillBranchCounts(list);
|
||||
fillExtendedFields(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量填充扩展字段:repoGroupName、branchCount
|
||||
* <p>使用批量查询避免N+1问题
|
||||
*/
|
||||
private void fillExtendedFields(List<RepositoryProjectDTO> projects) {
|
||||
if (projects.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 1. 收集所有仓库组ID
|
||||
Set<Long> repoGroupIds = projects.stream()
|
||||
.map(RepositoryProjectDTO::getRepoGroupId)
|
||||
.filter(id -> id != null)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 2. 批量查询仓库组信息
|
||||
Map<Long, RepositoryGroup> repoGroupMap = Collections.emptyMap();
|
||||
if (!repoGroupIds.isEmpty()) {
|
||||
repoGroupMap = repositoryGroupRepository.findAllById(repoGroupIds).stream()
|
||||
.collect(Collectors.toMap(RepositoryGroup::getId, Function.identity()));
|
||||
}
|
||||
|
||||
// 3. 填充仓库组名称
|
||||
Map<Long, RepositoryGroup> finalRepoGroupMap = repoGroupMap;
|
||||
projects.forEach(project -> {
|
||||
if (project.getRepoGroupId() != null) {
|
||||
RepositoryGroup group = finalRepoGroupMap.get(project.getRepoGroupId());
|
||||
if (group != null) {
|
||||
project.setRepoGroupName(group.getName());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 4. 填充分支数量
|
||||
fillBranchCounts(projects);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量填充项目的分支数量(解决N+1查询问题)
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user