|
@@ -1,23 +1,26 @@
|
|
|
-package cn.reghao.devops.mgr.build.controller.page;
|
|
|
|
|
|
|
+package cn.reghao.devops.mgr.build.controller;
|
|
|
|
|
|
|
|
import cn.reghao.devops.mgr.build.db.repository.DockerRegistryRepository;
|
|
import cn.reghao.devops.mgr.build.db.repository.DockerRegistryRepository;
|
|
|
import cn.reghao.devops.mgr.build.db.repository.PackerConfigRepository;
|
|
import cn.reghao.devops.mgr.build.db.repository.PackerConfigRepository;
|
|
|
import cn.reghao.devops.mgr.build.model.po.PackerConfig;
|
|
import cn.reghao.devops.mgr.build.model.po.PackerConfig;
|
|
|
import cn.reghao.devops.common.util.KeyValue;
|
|
import cn.reghao.devops.common.util.KeyValue;
|
|
|
|
|
+import cn.reghao.devops.mgr.build.service.PackerConfigService;
|
|
|
import cn.reghao.devops.mgr.util.PageSort;
|
|
import cn.reghao.devops.mgr.util.PageSort;
|
|
|
import cn.reghao.devops.common.machine.Machine;
|
|
import cn.reghao.devops.common.machine.Machine;
|
|
|
import cn.reghao.devops.common.msg.constant.PackType;
|
|
import cn.reghao.devops.common.msg.constant.PackType;
|
|
|
|
|
+import cn.reghao.jutil.jdk.result.Result;
|
|
|
|
|
+import cn.reghao.jutil.web.WebResult;
|
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
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.PageRequest;
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
|
|
+import org.springframework.http.MediaType;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
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.GetMapping;
|
|
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -33,11 +36,15 @@ import java.util.stream.Collectors;
|
|
|
@RequestMapping("/build/packer")
|
|
@RequestMapping("/build/packer")
|
|
|
public class PackerPageController {
|
|
public class PackerPageController {
|
|
|
private final PackerConfigRepository packerConfigRepository;
|
|
private final PackerConfigRepository packerConfigRepository;
|
|
|
- private final DockerRegistryRepository dockerRegistryRepository;
|
|
|
|
|
|
|
+ private final DockerRegistryRepository dockerRegistryRepository;;
|
|
|
|
|
+ private final PackerConfigService packerConfigService;
|
|
|
|
|
|
|
|
- public PackerPageController(PackerConfigRepository packerConfigRepository, DockerRegistryRepository dockerRegistryRepository) {
|
|
|
|
|
|
|
+ public PackerPageController(PackerConfigRepository packerConfigRepository,
|
|
|
|
|
+ DockerRegistryRepository dockerRegistryRepository,
|
|
|
|
|
+ PackerConfigService packerConfigService) {
|
|
|
this.packerConfigRepository = packerConfigRepository;
|
|
this.packerConfigRepository = packerConfigRepository;
|
|
|
this.dockerRegistryRepository = dockerRegistryRepository;
|
|
this.dockerRegistryRepository = dockerRegistryRepository;
|
|
|
|
|
+ this.packerConfigService = packerConfigService;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@ApiOperation(value = "打包配置页面", notes = "N")
|
|
@ApiOperation(value = "打包配置页面", notes = "N")
|
|
@@ -95,4 +102,22 @@ public class PackerPageController {
|
|
|
model.addAttribute("packer", packerConfig);
|
|
model.addAttribute("packer", packerConfig);
|
|
|
return "/devops/build/packer/detail";
|
|
return "/devops/build/packer/detail";
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "添加/修改应用打包配置", notes = "N")
|
|
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
|
|
+ @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public String addOrUpdatePackConfig(@Validated PackerConfig packerConfig) {
|
|
|
|
|
+ Result result = packerConfigService.addOrUpdate(packerConfig);
|
|
|
|
|
+ return WebResult.result(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "删除应用打包配置", notes = "N")
|
|
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
|
|
+ @DeleteMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public String deletePackConfig(@PathVariable("id") int id) {
|
|
|
|
|
+ Result result = packerConfigService.delete(id);
|
|
|
|
|
+ return WebResult.result(result);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|