|
|
@@ -1,5 +1,8 @@
|
|
|
package cn.reghao.autodop.dmaster.app.controller;
|
|
|
|
|
|
+import cn.reghao.autodop.common.utils.JsonUtil;
|
|
|
+import cn.reghao.autodop.dmaster.app.entity.orchestration.AppOrchestration;
|
|
|
+import cn.reghao.autodop.dmaster.app.entity.orchestration.ProjOrchestration;
|
|
|
import cn.reghao.autodop.dmaster.app.service.AppOrchestrateService;
|
|
|
import cn.reghao.autodop.dmaster.app.vo.BuildConfig;
|
|
|
import cn.reghao.autodop.dmaster.common.webresult.WebResult;
|
|
|
@@ -11,6 +14,9 @@ import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* @author reghao
|
|
|
* @date 2019-11-27 11:29:43
|
|
|
@@ -28,12 +34,38 @@ public class AppOrchestrateController {
|
|
|
|
|
|
@ApiOperation(value = "添加项目/应用编排")
|
|
|
@PostMapping(value = "/{type}", consumes = "application/json")
|
|
|
- public ResponseEntity<String>addOrchestration(@PathVariable("type") int type,
|
|
|
+ public ResponseEntity<String> addOrchestration(@PathVariable("type") int type,
|
|
|
@RequestBody String json) throws Exception {
|
|
|
+ /*switch (type) {
|
|
|
+ case 1:
|
|
|
+ ProjOrchestration proj = (ProjOrchestration) JsonUtil.jsonToObject(json, ProjOrchestration.class);
|
|
|
+ appOrchestrateService.addOrUpdateProj(proj);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ AppOrchestration app = (AppOrchestration) JsonUtil.jsonToObject(json, AppOrchestration.class);
|
|
|
+ checkApp(app);
|
|
|
+ appOrchestrateService.addOrUpdateApp(app);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }*/
|
|
|
appOrchestrateService.add(type, json);
|
|
|
return ResponseEntity.ok().body(WebResult.success("ok"));
|
|
|
}
|
|
|
|
|
|
+ //private void addOr
|
|
|
+
|
|
|
+ private void checkApp(AppOrchestration app) {
|
|
|
+ app.setConfigFiles(app.getConfigFiles().stream()
|
|
|
+ .filter(configFile -> !configFile.getFilename().isEmpty())
|
|
|
+ .collect(Collectors.toSet()));
|
|
|
+
|
|
|
+ app.setDependencyRepos(app.getDependencyRepos().stream()
|
|
|
+ .filter(dep -> !dep.isEmpty())
|
|
|
+ .collect(Collectors.toSet()));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "拷贝项目/应用编排")
|
|
|
@PostMapping(value = "/copy/{type}")
|
|
|
public ResponseEntity<String> copyOrchestration(@PathVariable("type") int type,
|
|
|
@@ -56,7 +88,7 @@ public class AppOrchestrateController {
|
|
|
|
|
|
@ApiOperation(value = "分页获取项目/应用编排(更新时间倒序)")
|
|
|
@GetMapping("/{type}")
|
|
|
- public ResponseEntity<String>getOrchestrationByPage(@PathVariable("type") int type,
|
|
|
+ public ResponseEntity<String> getOrchestrationByPage(@PathVariable("type") int type,
|
|
|
@RequestParam("env") String env,
|
|
|
@RequestParam("page") int page,
|
|
|
@RequestParam("size") int size) {
|
|
|
@@ -69,6 +101,8 @@ public class AppOrchestrateController {
|
|
|
@ApiOperation(value = "修改项目/应用编排")
|
|
|
@PutMapping("/{type}")
|
|
|
public ResponseEntity<String> modifyOrchestration(@PathVariable("type") int type, @RequestBody String json) {
|
|
|
+
|
|
|
+
|
|
|
boolean res = appOrchestrateService.modify(type, json);
|
|
|
if (res) {
|
|
|
return ResponseEntity.ok().body(WebResult.success("ok"));
|