|
@@ -5,7 +5,9 @@ import cn.reghao.autodop.dmaster.app.constant.EnvType;
|
|
|
import cn.reghao.autodop.dmaster.app.constant.NotifyType;
|
|
import cn.reghao.autodop.dmaster.app.constant.NotifyType;
|
|
|
import cn.reghao.autodop.dmaster.app.db.app.AppConfigQuery;
|
|
import cn.reghao.autodop.dmaster.app.db.app.AppConfigQuery;
|
|
|
import cn.reghao.autodop.dmaster.app.entity.config.AppOrchestration;
|
|
import cn.reghao.autodop.dmaster.app.entity.config.AppOrchestration;
|
|
|
|
|
+import cn.reghao.autodop.dmaster.app.entity.config.ProjOrchestration;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.config.AppOrchestrationRepository;
|
|
import cn.reghao.autodop.dmaster.app.repository.config.AppOrchestrationRepository;
|
|
|
|
|
+import cn.reghao.autodop.dmaster.app.repository.config.ProjOrchestrationRepository;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.config.build.CompilerConfigRepository;
|
|
import cn.reghao.autodop.dmaster.app.repository.config.build.CompilerConfigRepository;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.config.build.PackerConfigRepository;
|
|
import cn.reghao.autodop.dmaster.app.repository.config.build.PackerConfigRepository;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.config.build.RepoAuthConfigRepository;
|
|
import cn.reghao.autodop.dmaster.app.repository.config.build.RepoAuthConfigRepository;
|
|
@@ -16,13 +18,10 @@ import cn.reghao.autodop.dmaster.utils.db.PageList;
|
|
|
import cn.reghao.autodop.dmaster.utils.db.PageSort;
|
|
import cn.reghao.autodop.dmaster.utils.db.PageSort;
|
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
-import lombok.AllArgsConstructor;
|
|
|
|
|
-import lombok.Data;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageImpl;
|
|
import org.springframework.data.domain.PageImpl;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
-import org.springframework.data.domain.Sort;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.ui.Model;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -41,6 +40,7 @@ import java.util.stream.Collectors;
|
|
|
public class AppConfigPageController {
|
|
public class AppConfigPageController {
|
|
|
private AppConfigQuery appConfigQuery;
|
|
private AppConfigQuery appConfigQuery;
|
|
|
private AppOrchestrationRepository appRepository;
|
|
private AppOrchestrationRepository appRepository;
|
|
|
|
|
+ private ProjOrchestrationRepository projRepository;
|
|
|
private RepoAuthConfigRepository repoAuthRepository;
|
|
private RepoAuthConfigRepository repoAuthRepository;
|
|
|
private CompilerConfigRepository compilerRepository;
|
|
private CompilerConfigRepository compilerRepository;
|
|
|
private PackerConfigRepository packerRepository;
|
|
private PackerConfigRepository packerRepository;
|
|
@@ -48,12 +48,14 @@ public class AppConfigPageController {
|
|
|
|
|
|
|
|
public AppConfigPageController(AppConfigQuery appConfigQuery,
|
|
public AppConfigPageController(AppConfigQuery appConfigQuery,
|
|
|
AppOrchestrationRepository appRepository,
|
|
AppOrchestrationRepository appRepository,
|
|
|
|
|
+ ProjOrchestrationRepository projRepository,
|
|
|
RepoAuthConfigRepository repoAuthRepository,
|
|
RepoAuthConfigRepository repoAuthRepository,
|
|
|
CompilerConfigRepository compilerRepository,
|
|
CompilerConfigRepository compilerRepository,
|
|
|
PackerConfigRepository packerRepository,
|
|
PackerConfigRepository packerRepository,
|
|
|
MachineInfoRepository machineRepository) {
|
|
MachineInfoRepository machineRepository) {
|
|
|
this.appConfigQuery = appConfigQuery;
|
|
this.appConfigQuery = appConfigQuery;
|
|
|
this.appRepository = appRepository;
|
|
this.appRepository = appRepository;
|
|
|
|
|
+ this.projRepository = projRepository;
|
|
|
this.repoAuthRepository = repoAuthRepository;
|
|
this.repoAuthRepository = repoAuthRepository;
|
|
|
this.compilerRepository = compilerRepository;
|
|
this.compilerRepository = compilerRepository;
|
|
|
this.packerRepository = packerRepository;
|
|
this.packerRepository = packerRepository;
|
|
@@ -94,11 +96,11 @@ public class AppConfigPageController {
|
|
|
|
|
|
|
|
@GetMapping("/app/add")
|
|
@GetMapping("/app/add")
|
|
|
public String addAppConfigPage(Model model) {
|
|
public String addAppConfigPage(Model model) {
|
|
|
- setModel(model);
|
|
|
|
|
|
|
+ setAppModel(model);
|
|
|
return "/app/config/app/add";
|
|
return "/app/config/app/add";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void setModel(Model model) {
|
|
|
|
|
|
|
+ private void setAppModel(Model model) {
|
|
|
List<KeyValue> envs = new ArrayList<>();
|
|
List<KeyValue> envs = new ArrayList<>();
|
|
|
for (EnvType envType : EnvType.values()) {
|
|
for (EnvType envType : EnvType.values()) {
|
|
|
envs.add(new KeyValue(envType.name(), envType.name()));
|
|
envs.add(new KeyValue(envType.name(), envType.name()));
|
|
@@ -146,7 +148,7 @@ public class AppConfigPageController {
|
|
|
|
|
|
|
|
@GetMapping("/app/edit/{id}")
|
|
@GetMapping("/app/edit/{id}")
|
|
|
public String editAppConfigPage(@PathVariable("id") AppOrchestration app, Model model) {
|
|
public String editAppConfigPage(@PathVariable("id") AppOrchestration app, Model model) {
|
|
|
- setModel(model);
|
|
|
|
|
|
|
+ setAppModel(model);
|
|
|
model.addAttribute("app", app);
|
|
model.addAttribute("app", app);
|
|
|
return "/app/config/app/add";
|
|
return "/app/config/app/add";
|
|
|
}
|
|
}
|
|
@@ -167,18 +169,69 @@ public class AppConfigPageController {
|
|
|
|
|
|
|
|
@ApiOperation(value = "项目配置页面")
|
|
@ApiOperation(value = "项目配置页面")
|
|
|
@GetMapping("/proj")
|
|
@GetMapping("/proj")
|
|
|
- public String projConfigPage(Model model) {
|
|
|
|
|
- String env = EnvType.test.name();
|
|
|
|
|
- int page = 1;
|
|
|
|
|
- int size = 10;
|
|
|
|
|
- PageRequest pageRequest =
|
|
|
|
|
- PageRequest.of(page-1, size, Sort.by(Sort.Direction.DESC, "updateTime"));
|
|
|
|
|
|
|
+ public String projConfigPage(@RequestParam(value = "projName", required = false) String projName, Model model) {
|
|
|
|
|
|
|
|
- Page<AppOrchestration> appPage = appRepository.findByEnableTrueAndEnv(env, pageRequest);
|
|
|
|
|
- PageList<AppOrchestration> pageList = PageList.pageList(appPage);
|
|
|
|
|
|
|
+ /*if (projName != null) {
|
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
|
|
+ map.put("projName", projName);
|
|
|
|
|
+ List<AppOrchestration> list = appConfigQuery.query(map);
|
|
|
|
|
+ Page<AppOrchestration> page = new PageImpl<>(list);
|
|
|
|
|
+ PageList<AppOrchestration> pageList = PageList.pageList(page);
|
|
|
|
|
|
|
|
- model.addAttribute("page", appPage);
|
|
|
|
|
|
|
+ model.addAttribute("page", page);
|
|
|
|
|
+ model.addAttribute("list", pageList.getList());
|
|
|
|
|
+ return "/app/config/app/index";
|
|
|
|
|
+ }*/
|
|
|
|
|
+
|
|
|
|
|
+ PageRequest pageRequest = PageSort.pageRequest();
|
|
|
|
|
+ Page<ProjOrchestration> page = projRepository.findByIsDeleteFalse(pageRequest);
|
|
|
|
|
+ PageList<ProjOrchestration> pageList = PageList.pageList(page);
|
|
|
|
|
+
|
|
|
|
|
+ model.addAttribute("page", page);
|
|
|
model.addAttribute("list", pageList.getList());
|
|
model.addAttribute("list", pageList.getList());
|
|
|
return "/app/config/proj/index";
|
|
return "/app/config/proj/index";
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/proj/add")
|
|
|
|
|
+ public String addProjConfigPage(Model model) {
|
|
|
|
|
+ setProjModel(model);
|
|
|
|
|
+ return "/app/config/proj/add";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void setProjModel(Model model) {
|
|
|
|
|
+ List<KeyValue> repoAuths = repoAuthRepository.findAllByIsDeleteFalse().stream()
|
|
|
|
|
+ .map(repoAuthConfig -> new KeyValue(String.valueOf(repoAuthConfig.getId()), repoAuthConfig.getName()))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ List<KeyValue> compilers = compilerRepository.findAllByIsDeleteFalse().stream()
|
|
|
|
|
+ .map(compilerConfig -> new KeyValue(String.valueOf(compilerConfig.getId()), compilerConfig.getName()))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ List<KeyValue> packers = packerRepository.findAllByIsDeleteFalse().stream()
|
|
|
|
|
+ .map(packerConfig -> new KeyValue(String.valueOf(packerConfig.getId()), packerConfig.getName()))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ model.addAttribute("repoAuths", repoAuths);
|
|
|
|
|
+ model.addAttribute("compilers", compilers);
|
|
|
|
|
+ model.addAttribute("packers", packers);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/proj/edit/{id}")
|
|
|
|
|
+ public String editProjConfigPage(@PathVariable("id") ProjOrchestration proj, Model model) {
|
|
|
|
|
+ setAppModel(model);
|
|
|
|
|
+ model.addAttribute("proj", proj);
|
|
|
|
|
+ return "/app/config/proj/add";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/proj/copy/{id}")
|
|
|
|
|
+ public String copyProjConfigPage(@PathVariable("id") ProjOrchestration proj, Model model) {
|
|
|
|
|
+ model.addAttribute("proj", proj);
|
|
|
|
|
+ return "/app/config/proj/copy";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "项目配置详情页面")
|
|
|
|
|
+ @GetMapping("/proj/detail/{projId}")
|
|
|
|
|
+ public String projConfigDetailPage(@PathVariable("projId") String projId, Model model) {
|
|
|
|
|
+ ProjOrchestration proj = projRepository.findByIsDeleteFalseAndProjId(projId);
|
|
|
|
|
+ model.addAttribute("proj", proj);
|
|
|
|
|
+ return "/app/config/proj/detail";
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|