|
|
@@ -1,16 +1,34 @@
|
|
|
package cn.reghao.autodop.dmaster.app.controller.view;
|
|
|
|
|
|
-import cn.reghao.autodop.dmaster.app.constant.EnvType;
|
|
|
+import cn.reghao.autodop.common.dagent.app.api.data.deploy.PackType;
|
|
|
+import cn.reghao.autodop.dmaster.app.constant.build.CompileType;
|
|
|
+import cn.reghao.autodop.dmaster.app.constant.build.RepoAuthType;
|
|
|
+import cn.reghao.autodop.dmaster.app.constant.build.RepoType;
|
|
|
+import cn.reghao.autodop.dmaster.app.entity.config.build.BuildDir;
|
|
|
+import cn.reghao.autodop.dmaster.app.entity.config.build.CompilerConfig;
|
|
|
+import cn.reghao.autodop.dmaster.app.entity.config.build.PackerConfig;
|
|
|
+import cn.reghao.autodop.dmaster.app.entity.config.build.RepoAuthConfig;
|
|
|
+import cn.reghao.autodop.dmaster.app.repository.config.build.BuildDirRepository;
|
|
|
+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.RepoAuthConfigRepository;
|
|
|
+import cn.reghao.autodop.dmaster.app.vo.KeyValue;
|
|
|
+import cn.reghao.autodop.dmaster.utils.db.PageList;
|
|
|
+import cn.reghao.autodop.dmaster.utils.db.PageSort;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
-import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.Model;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* @author reghao
|
|
|
* @date 2019-08-30 18:49:15
|
|
|
@@ -20,17 +38,165 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
@Controller
|
|
|
@RequestMapping("/app/config/build")
|
|
|
public class BuildConfigPageController {
|
|
|
- public BuildConfigPageController() {
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "构建页面")
|
|
|
- @GetMapping("/repo")
|
|
|
- public String buildPage(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"));
|
|
|
- return "/app/build";
|
|
|
+ private BuildDirRepository buildDirRepository;
|
|
|
+ private RepoAuthConfigRepository repoAuthRepository;
|
|
|
+ private CompilerConfigRepository compilerRepository;
|
|
|
+ private PackerConfigRepository packerRepository;
|
|
|
+
|
|
|
+ public BuildConfigPageController(BuildDirRepository buildDirRepository,
|
|
|
+ RepoAuthConfigRepository repoAuthRepository,
|
|
|
+ CompilerConfigRepository compilerRepository,
|
|
|
+ PackerConfigRepository packerRepository) {
|
|
|
+ this.buildDirRepository = buildDirRepository;
|
|
|
+ this.repoAuthRepository = repoAuthRepository;
|
|
|
+ this.compilerRepository = compilerRepository;
|
|
|
+ this.packerRepository = packerRepository;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "构建目录页面")
|
|
|
+ @GetMapping("/dir")
|
|
|
+ public String buildDirPage(Model model) {
|
|
|
+ PageRequest pageRequest = PageSort.pageRequest();
|
|
|
+ Page<BuildDir> page = buildDirRepository.findAll(pageRequest);
|
|
|
+ PageList<BuildDir> pageList = PageList.pageList(page);
|
|
|
+
|
|
|
+ model.addAttribute("page", page);
|
|
|
+ model.addAttribute("list", pageList.getList());
|
|
|
+ return "/app/config/builddir/index";
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/dir/add")
|
|
|
+ public String addAppConfigPage(Model model) {
|
|
|
+ return "/app/config/builddir/add";
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/dir/edit/{id}")
|
|
|
+ public String editAppConfigPage(@PathVariable("id") BuildDir buildDir, Model model) {
|
|
|
+ model.addAttribute("buildDir", buildDir);
|
|
|
+ return "/app/config/builddir/add";
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "仓库认证页面")
|
|
|
+ @GetMapping("/repoauth")
|
|
|
+ public String repoAuthPage(Model model) {
|
|
|
+ PageRequest pageRequest = PageSort.pageRequest();
|
|
|
+ Page<RepoAuthConfig> page = repoAuthRepository.findAll(pageRequest);
|
|
|
+ PageList<RepoAuthConfig> pageList = PageList.pageList(page);
|
|
|
+
|
|
|
+ model.addAttribute("page", page);
|
|
|
+ model.addAttribute("list", pageList.getList());
|
|
|
+ return "/app/config/repoauth/index";
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/repoauth/add")
|
|
|
+ public String addRepoAuthPage(Model model) {
|
|
|
+ setRepoAuthModel(model);
|
|
|
+ return "/app/config/repoauth/add";
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/repoauth/edit/{id}")
|
|
|
+ public String editRepoAuthPage(@PathVariable("id") RepoAuthConfig repoAuth, Model model) {
|
|
|
+ setRepoAuthModel(model);
|
|
|
+ model.addAttribute("repoAuth", repoAuth);
|
|
|
+ return "/app/config/repoauth/add";
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setRepoAuthModel(Model model) {
|
|
|
+ List<KeyValue> repos = new ArrayList<>();
|
|
|
+ for (RepoType repoType : RepoType.values()) {
|
|
|
+ repos.add(new KeyValue(repoType.name(), repoType.name()));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<KeyValue> auths = new ArrayList<>();
|
|
|
+ for (RepoAuthType authType : RepoAuthType.values()) {
|
|
|
+ auths.add(new KeyValue(authType.name(), authType.name()));
|
|
|
+ }
|
|
|
+
|
|
|
+ model.addAttribute("repos", repos);
|
|
|
+ model.addAttribute("auths", auths);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/repoauth/detail/{id}")
|
|
|
+ public String repoAuthDetailPage(@PathVariable("id") RepoAuthConfig repoAuth, Model model) {
|
|
|
+ model.addAttribute("repoAuth", repoAuth);
|
|
|
+ return "/app/config/repoauth/detail";
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "编译配置页面")
|
|
|
+ @GetMapping("/compiler")
|
|
|
+ public String compilerConfigPage(Model model) {
|
|
|
+ PageRequest pageRequest = PageSort.pageRequest();
|
|
|
+ Page<CompilerConfig> page = compilerRepository.findAll(pageRequest);
|
|
|
+ PageList<CompilerConfig> pageList = PageList.pageList(page);
|
|
|
+
|
|
|
+ model.addAttribute("page", page);
|
|
|
+ model.addAttribute("list", pageList.getList());
|
|
|
+ return "/app/config/compiler/index";
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/compiler/add")
|
|
|
+ public String addCompilerPage(Model model) {
|
|
|
+ setCompilerModel(model);
|
|
|
+ return "/app/config/compiler/add";
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/compiler/edit/{id}")
|
|
|
+ public String editCompilerPage(@PathVariable("id") CompilerConfig compilerConfig, Model model) {
|
|
|
+ setCompilerModel(model);
|
|
|
+ model.addAttribute("compiler", compilerConfig);
|
|
|
+ return "/app/config/compiler/add";
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setCompilerModel(Model model) {
|
|
|
+ List<KeyValue> compileTypes = new ArrayList<>();
|
|
|
+ for (CompileType compileType : CompileType.values()) {
|
|
|
+ compileTypes.add(new KeyValue(compileType.name(), compileType.name()));
|
|
|
+ }
|
|
|
+ model.addAttribute("compileTypes", compileTypes);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/compiler/detail/{id}")
|
|
|
+ public String compilerDetailPage(@PathVariable("id") CompilerConfig compilerConfig, Model model) {
|
|
|
+ model.addAttribute("compiler", compilerConfig);
|
|
|
+ return "/app/config/compiler/detail";
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "打包配置页面")
|
|
|
+ @GetMapping("/packer")
|
|
|
+ public String packerPage(Model model) {
|
|
|
+ PageRequest pageRequest = PageSort.pageRequest();
|
|
|
+ Page<PackerConfig> page = packerRepository.findAll(pageRequest);
|
|
|
+ PageList<PackerConfig> pageList = PageList.pageList(page);
|
|
|
+
|
|
|
+ model.addAttribute("page", page);
|
|
|
+ model.addAttribute("list", pageList.getList());
|
|
|
+ return "/app/config/packer/index";
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/packer/add")
|
|
|
+ public String addPackerPage(Model model) {
|
|
|
+ setPackerModel(model);
|
|
|
+ return "/app/config/packer/add";
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/packer/edit/{id}")
|
|
|
+ public String editPackerPage(@PathVariable("id") PackerConfig packerConfig, Model model) {
|
|
|
+ setPackerModel(model);
|
|
|
+ model.addAttribute("packer", packerConfig);
|
|
|
+ return "/app/config/packer/add";
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setPackerModel(Model model) {
|
|
|
+ List<KeyValue> packTypes = new ArrayList<>();
|
|
|
+ for (PackType packType : PackType.values()) {
|
|
|
+ packTypes.add(new KeyValue(packType.name(), packType.name()));
|
|
|
+ }
|
|
|
+ model.addAttribute("packTypes", packTypes);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/packer/detail/{id}")
|
|
|
+ public String packerDetailPage(@PathVariable("id") PackerConfig packerConfig, Model model) {
|
|
|
+ model.addAttribute("packer", packerConfig);
|
|
|
+ return "/app/config/packer/detail";
|
|
|
}
|
|
|
}
|