单独同步GIT
This commit is contained in:
parent
58491de2f0
commit
bd984da237
@ -73,4 +73,9 @@ public class RepositoryGroupDTO extends BaseDTO {
|
||||
*/
|
||||
private Long externalSystemId;
|
||||
|
||||
/**
|
||||
* 该仓库组下的项目数量(反显字段)
|
||||
*/
|
||||
private Long projectCount;
|
||||
|
||||
}
|
||||
@ -36,4 +36,9 @@ public class RepositoryProjectDTO extends BaseDTO {
|
||||
private Long repoGroupId;
|
||||
|
||||
private Long repoProjectId;
|
||||
|
||||
/**
|
||||
* 该项目下的分支数量(反显字段)
|
||||
*/
|
||||
private Long branchCount;
|
||||
}
|
||||
@ -34,6 +34,15 @@ public interface IRepositoryBranchRepository extends IBaseRepository<RepositoryB
|
||||
*/
|
||||
Long countByProjectId(Long projectId);
|
||||
|
||||
/**
|
||||
* 统计指定仓库项目下的分支数量(未删除)
|
||||
*
|
||||
* @param externalSystemId 外部系统ID
|
||||
* @param repoProjectId GitLab项目ID
|
||||
* @return 分支数量
|
||||
*/
|
||||
Long countByExternalSystemIdAndRepoProjectIdAndDeletedFalse(Long externalSystemId, Long repoProjectId);
|
||||
|
||||
List<RepositoryBranch> findByExternalSystemIdAndProjectIdAndDeletedFalse(Long externalSystemId, Long id);
|
||||
|
||||
List<RepositoryBranch> findByExternalSystemIdAndDeletedFalse(Long externalSystemId);
|
||||
|
||||
@ -27,6 +27,15 @@ public interface IRepositoryProjectRepository extends IBaseRepository<Repository
|
||||
*/
|
||||
Long countByExternalSystemId(Long externalSystemId);
|
||||
|
||||
/**
|
||||
* 统计指定仓库组下的项目数量(未删除)
|
||||
*
|
||||
* @param externalSystemId 外部系统ID
|
||||
* @param repoGroupId 仓库组ID
|
||||
* @return 项目数量
|
||||
*/
|
||||
Long countByExternalSystemIdAndRepoGroupIdAndDeletedFalse(Long externalSystemId, Long repoGroupId);
|
||||
|
||||
List<RepositoryProject> findByExternalSystemId(Long externalSystemId);
|
||||
|
||||
void deleteByExternalSystemId(Long externalSystemId);
|
||||
|
||||
@ -12,6 +12,7 @@ import com.qqchen.deploy.backend.deploy.integration.response.GitGroupResponse;
|
||||
import com.qqchen.deploy.backend.deploy.query.RepositoryGroupQuery;
|
||||
import com.qqchen.deploy.backend.deploy.repository.IExternalSystemRepository;
|
||||
import com.qqchen.deploy.backend.deploy.repository.IRepositoryGroupRepository;
|
||||
import com.qqchen.deploy.backend.deploy.repository.IRepositoryProjectRepository;
|
||||
import com.qqchen.deploy.backend.deploy.service.IRepositoryGroupService;
|
||||
import com.qqchen.deploy.backend.deploy.service.IRepositorySyncHistoryService;
|
||||
import com.qqchen.deploy.backend.framework.enums.ResponseCode;
|
||||
@ -19,6 +20,9 @@ import com.qqchen.deploy.backend.framework.exception.BusinessException;
|
||||
import com.qqchen.deploy.backend.framework.service.impl.BaseServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -43,6 +47,9 @@ public class RepositoryGroupServiceImpl extends BaseServiceImpl<RepositoryGroup,
|
||||
@Resource
|
||||
private IRepositoryGroupRepository repositoryGroupRepository;
|
||||
|
||||
@Resource
|
||||
private IRepositoryProjectRepository repositoryProjectRepository;
|
||||
|
||||
@Resource
|
||||
private IGitServiceIntegration gitServiceIntegration;
|
||||
|
||||
@ -126,4 +133,32 @@ public class RepositoryGroupServiceImpl extends BaseServiceImpl<RepositoryGroup,
|
||||
public List<RepositoryGroupDTO> findByExternalSystemId(Long externalSystemId) {
|
||||
return repositoryGroupConverter.toDtoList(repositoryGroupRepository.findByExternalSystemId(externalSystemId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<RepositoryGroupDTO> page(RepositoryGroupQuery query) {
|
||||
Page<RepositoryGroupDTO> page = super.page(query);
|
||||
List<RepositoryGroupDTO> result = page.getContent().stream().peek(group -> {
|
||||
// 统计该仓库组下的项目数量
|
||||
Long projectCount = repositoryProjectRepository.countByExternalSystemIdAndRepoGroupIdAndDeletedFalse(
|
||||
group.getExternalSystemId(),
|
||||
group.getRepoGroupId()
|
||||
);
|
||||
group.setProjectCount(projectCount);
|
||||
}).collect(Collectors.toList());
|
||||
return new PageImpl<>(result, page.getPageable(), page.getTotalElements());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RepositoryGroupDTO> findAll(RepositoryGroupQuery query) {
|
||||
List<RepositoryGroupDTO> list = super.findAll(query);
|
||||
list.forEach(group -> {
|
||||
// 统计该仓库组下的项目数量
|
||||
Long projectCount = repositoryProjectRepository.countByExternalSystemIdAndRepoGroupIdAndDeletedFalse(
|
||||
group.getExternalSystemId(),
|
||||
group.getRepoGroupId()
|
||||
);
|
||||
group.setProjectCount(projectCount);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@ -14,6 +14,7 @@ import com.qqchen.deploy.backend.deploy.query.RepositoryProjectQuery;
|
||||
import com.qqchen.deploy.backend.deploy.repository.IExternalSystemRepository;
|
||||
import com.qqchen.deploy.backend.deploy.repository.IRepositoryGroupRepository;
|
||||
import com.qqchen.deploy.backend.deploy.repository.IRepositoryProjectRepository;
|
||||
import com.qqchen.deploy.backend.deploy.repository.IRepositoryBranchRepository;
|
||||
import com.qqchen.deploy.backend.deploy.service.IRepositoryProjectService;
|
||||
import com.qqchen.deploy.backend.deploy.service.IRepositorySyncHistoryService;
|
||||
import com.qqchen.deploy.backend.framework.enums.ResponseCode;
|
||||
@ -21,6 +22,9 @@ import com.qqchen.deploy.backend.framework.exception.BusinessException;
|
||||
import com.qqchen.deploy.backend.framework.service.impl.BaseServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.orm.ObjectOptimisticLockingFailureException;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
@ -55,6 +59,9 @@ public class RepositoryProjectServiceImpl extends BaseServiceImpl<RepositoryProj
|
||||
@Resource
|
||||
private IRepositoryProjectRepository repositoryProjectRepository;
|
||||
|
||||
@Resource
|
||||
private IRepositoryBranchRepository repositoryBranchRepository;
|
||||
|
||||
@Resource
|
||||
private IGitServiceIntegration gitServiceIntegration;
|
||||
|
||||
@ -296,4 +303,32 @@ public class RepositoryProjectServiceImpl extends BaseServiceImpl<RepositoryProj
|
||||
public List<RepositoryProjectDTO> findByExternalSystemId(Long externalSystemId) {
|
||||
return repositoryProjectConverter.toDtoList(repositoryProjectRepository.findByExternalSystemId(externalSystemId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<RepositoryProjectDTO> page(RepositoryProjectQuery query) {
|
||||
Page<RepositoryProjectDTO> page = super.page(query);
|
||||
List<RepositoryProjectDTO> result = page.getContent().stream().peek(project -> {
|
||||
// 统计该项目下的分支数量
|
||||
Long branchCount = repositoryBranchRepository.countByExternalSystemIdAndRepoProjectIdAndDeletedFalse(
|
||||
project.getExternalSystemId(),
|
||||
project.getRepoProjectId()
|
||||
);
|
||||
project.setBranchCount(branchCount);
|
||||
}).collect(Collectors.toList());
|
||||
return new PageImpl<>(result, page.getPageable(), page.getTotalElements());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RepositoryProjectDTO> findAll(RepositoryProjectQuery query) {
|
||||
List<RepositoryProjectDTO> list = super.findAll(query);
|
||||
list.forEach(project -> {
|
||||
// 统计该项目下的分支数量
|
||||
Long branchCount = repositoryBranchRepository.countByExternalSystemIdAndRepoProjectIdAndDeletedFalse(
|
||||
project.getExternalSystemId(),
|
||||
project.getRepoProjectId()
|
||||
);
|
||||
project.setBranchCount(branchCount);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user