|
@@ -2,11 +2,14 @@ package cn.reghao.bnt.web.devops.app.db.query.impl;
|
|
|
|
|
|
|
|
import cn.reghao.bnt.web.devops.app.db.query.AppConfigQuery;
|
|
import cn.reghao.bnt.web.devops.app.db.query.AppConfigQuery;
|
|
|
import cn.reghao.bnt.web.devops.app.db.repository.config.AppConfigRepository;
|
|
import cn.reghao.bnt.web.devops.app.db.repository.config.AppConfigRepository;
|
|
|
|
|
+import cn.reghao.bnt.web.devops.app.db.repository.config.AppDeployConfigRepository;
|
|
|
import cn.reghao.bnt.web.devops.app.model.po.config.AppConfig;
|
|
import cn.reghao.bnt.web.devops.app.model.po.config.AppConfig;
|
|
|
import cn.reghao.bnt.web.devops.app.model.po.config.build.CompilerConfig;
|
|
import cn.reghao.bnt.web.devops.app.model.po.config.build.CompilerConfig;
|
|
|
import cn.reghao.bnt.web.devops.app.model.po.config.build.PackerConfig;
|
|
import cn.reghao.bnt.web.devops.app.model.po.config.build.PackerConfig;
|
|
|
import cn.reghao.bnt.web.devops.app.model.po.config.build.RepoAuthConfig;
|
|
import cn.reghao.bnt.web.devops.app.model.po.config.build.RepoAuthConfig;
|
|
|
|
|
+import cn.reghao.bnt.web.devops.app.model.vo.AppConfigVO;
|
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
|
|
|
+import org.springframework.data.domain.PageImpl;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -15,6 +18,7 @@ import javax.persistence.criteria.Predicate;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author reghao
|
|
* @author reghao
|
|
@@ -23,9 +27,11 @@ import java.util.Map;
|
|
|
@Service
|
|
@Service
|
|
|
public class AppConfigQueryImpl implements AppConfigQuery {
|
|
public class AppConfigQueryImpl implements AppConfigQuery {
|
|
|
private final AppConfigRepository appRepository;
|
|
private final AppConfigRepository appRepository;
|
|
|
|
|
+ private AppDeployConfigRepository deployConfigRepository;
|
|
|
|
|
|
|
|
- public AppConfigQueryImpl(AppConfigRepository appRepository) {
|
|
|
|
|
|
|
+ public AppConfigQueryImpl(AppConfigRepository appRepository, AppDeployConfigRepository deployConfigRepository) {
|
|
|
this.appRepository = appRepository;
|
|
this.appRepository = appRepository;
|
|
|
|
|
+ this.deployConfigRepository = deployConfigRepository;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -65,8 +71,16 @@ public class AppConfigQueryImpl implements AppConfigQuery {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public Page<AppConfig> findByEnvAndType(String env, String type, Pageable pageable) {
|
|
|
|
|
- return appRepository.findByEnvAndAppType(env, type, pageable);
|
|
|
|
|
|
|
+ public Page<AppConfigVO> findByEnvAndType(String env, String type, Pageable pageable) {
|
|
|
|
|
+ Page<AppConfig> page = appRepository.findByEnvAndAppType(env, type, pageable);
|
|
|
|
|
+
|
|
|
|
|
+ List<AppConfigVO> list = page.stream()
|
|
|
|
|
+ .map(appConfig -> {
|
|
|
|
|
+ int total = deployConfigRepository.countByAppConfig(appConfig);
|
|
|
|
|
+ return new AppConfigVO(appConfig, total);
|
|
|
|
|
+ })
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ return new PageImpl<>(list, page.getPageable(), page.getTotalElements());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//@Cacheable({"appId"})
|
|
//@Cacheable({"appId"})
|