|
|
@@ -1,19 +1,26 @@
|
|
|
package cn.reghao.autodop.dmaster.app.service;
|
|
|
|
|
|
+import cn.reghao.autodop.dmaster.app.cache.BuildDeployCache;
|
|
|
+import cn.reghao.autodop.dmaster.app.entity.config.orchestration.AppOrchestration;
|
|
|
+import cn.reghao.autodop.dmaster.app.entity.deploy.DeployConfig;
|
|
|
import cn.reghao.autodop.dmaster.app.entity.log.BuildDeployApp;
|
|
|
import cn.reghao.autodop.dmaster.app.entity.log.BuildLog;
|
|
|
+import cn.reghao.autodop.dmaster.app.entity.log.DeployLog;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.log.BuildLogRepository;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.log.CommitLogRepository;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.log.DeployLogRepository;
|
|
|
import cn.reghao.autodop.dmaster.app.entity.log.CommitLog;
|
|
|
import cn.reghao.autodop.common.utils.data.db.PageList;
|
|
|
import cn.reghao.autodop.dmaster.app.service.crud.BuildDeployAppCrudService;
|
|
|
+import cn.reghao.autodop.dmaster.app.vo.CurrentRunningCommit;
|
|
|
import cn.reghao.autodop.dmaster.app.vo.SuccessfullyBuildVO;
|
|
|
import cn.reghao.autodop.dmaster.app.vo.log.*;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
+import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -22,30 +29,32 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
@Service
|
|
|
public class BuildService {
|
|
|
+ private BuildDeployCache cache;
|
|
|
private BuildDeployAppCrudService buildDeployAppCrudService;
|
|
|
private CommitLogRepository commitLogRepository;
|
|
|
private BuildLogRepository buildLogRepository;
|
|
|
private DeployLogRepository deployLogRepository;
|
|
|
|
|
|
- public BuildService(BuildDeployAppCrudService buildDeployAppCrudService,
|
|
|
+ public BuildService(BuildDeployCache cache,
|
|
|
+ BuildDeployAppCrudService buildDeployAppCrudService,
|
|
|
CommitLogRepository commitLogRepository,
|
|
|
BuildLogRepository buildLogRepository,
|
|
|
DeployLogRepository deployLogRepository) {
|
|
|
+ this.cache = cache;
|
|
|
this.buildDeployAppCrudService = buildDeployAppCrudService;
|
|
|
this.commitLogRepository = commitLogRepository;
|
|
|
this.buildLogRepository = buildLogRepository;
|
|
|
this.deployLogRepository = deployLogRepository;
|
|
|
}
|
|
|
|
|
|
- public PageList<BuildDeployApp> buildList(int page, int size, String env) {
|
|
|
+ public PageList<BuildDeployAppVO> buildList(int page, int size, String env) {
|
|
|
PageList<BuildDeployApp> pageList = buildDeployAppCrudService.getByPage(page, size);
|
|
|
- PageList<BuildDeployApp> vos = new PageList<>();
|
|
|
+ PageList<BuildDeployAppVO> vos = new PageList<>();
|
|
|
vos.setTotalPages(pageList.getTotalPages());
|
|
|
vos.setTotalSize(pageList.getTotalSize());
|
|
|
vos.setPageSize(vos.getPageSize());
|
|
|
vos.setHasNext(pageList.isHasNext());
|
|
|
- vos.setList(pageList.getList().stream().map(BuildDeployApp::vo).collect(Collectors.toList()));
|
|
|
-
|
|
|
+ vos.setList(pageList.getList().stream().map(BuildDeployAppVO::of).collect(Collectors.toList()));
|
|
|
return vos;
|
|
|
}
|
|
|
|
|
|
@@ -114,4 +123,30 @@ public class BuildService {
|
|
|
pageList.setList(deployLogs.stream().map(DeployLogVO::from).collect(Collectors.toList()));*/
|
|
|
return pageList;
|
|
|
}
|
|
|
+
|
|
|
+ public PageList<CurrentRunningCommit> deployedApp(String appId, int page, int size) {
|
|
|
+ PageRequest pageRequest =
|
|
|
+ PageRequest.of(page-1, size, Sort.by(Sort.Direction.DESC, "createTime"));
|
|
|
+ Page<DeployLog> deployLogs = deployLogRepository.findDeployLogByAppId(appId, pageRequest);
|
|
|
+ List<CurrentRunningCommit> apps = deployLogs.getContent().stream()
|
|
|
+ .map(deployLog -> new CurrentRunningCommit(deployLog.getMachineId(), deployLog.getCommitId(), ""))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ PageList<CurrentRunningCommit> pageList = new PageList<>();
|
|
|
+ AppOrchestration app = cache.findByAppId(appId);
|
|
|
+ if (app == null) {
|
|
|
+ return pageList;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<DeployConfig> deployConfigs = app.getDeployConfigs();
|
|
|
+ pageList.setPageSize(deployConfigs.size());
|
|
|
+ pageList.setTotalSize(deployConfigs.size());
|
|
|
+ pageList.setTotalPages(1);
|
|
|
+ pageList.setHasNext(false);
|
|
|
+ pageList.setList(apps);
|
|
|
+ /*pageList.setList(deployConfigs.stream()
|
|
|
+ .map(deployConfig -> new LatestDeployedApp(deployConfig.getMachineId()))
|
|
|
+ .collect(Collectors.toList()));*/
|
|
|
+ return pageList;
|
|
|
+ }
|
|
|
}
|