Explorar o código

调整 AppConfig 更新接口

reghao hai 1 semana
pai
achega
58cfaeb532

+ 2 - 4
mgr/src/main/java/cn/reghao/devops/mgr/ops/app/model/dto/AppConfigUpdateDto.java

@@ -20,11 +20,9 @@ public class AppConfigUpdateDto {
     private String repoBranch;
 
     // buildConfig
-    @NotNull(message = "必须指定仓库认证")
-    private Integer repoAuthConfigId;
     @NotNull(message = "必须指定编译配置")
-    private Integer compilerConfigId;
+    private String compilerConfig;
     @NotNull(message = "必须指定打包配置")
-    private Integer packerConfigId;
+    private String packerConfig;
     private String dockerfile;
 }

+ 0 - 1
mgr/src/main/java/cn/reghao/devops/mgr/ops/app/model/po/AppConfig.java

@@ -91,7 +91,6 @@ public class AppConfig extends BaseEntity implements Cloneable {
 
     public AppConfig update(AppConfigUpdateDto appConfigUpdateDto, BuildConfig buildConfig) {
         this.repoBranch = appConfigUpdateDto.getRepoBranch();
-        this.repoAuthConfig = buildConfig.getRepoAuth();
         this.compilerConfig = buildConfig.getCompiler();
         this.packerConfig = buildConfig.getPacker();
         this.dockerfile = appConfigUpdateDto.getDockerfile();

+ 3 - 4
mgr/src/main/java/cn/reghao/devops/mgr/ops/app/service/impl/AppBuildServiceImpl.java

@@ -127,10 +127,9 @@ public class AppBuildServiceImpl implements AppBuildService {
             buildDirService.eraseLocalRepo(appId);
         }
 
-        int repoAuthId = appConfigUpdateDto.getRepoAuthConfigId();
-        int compilerId = appConfigUpdateDto.getCompilerConfigId();
-        int packerId = appConfigUpdateDto.getPackerConfigId();
-        BuildConfig buildConfig = buildConfigChecker.checkAndGet(repoAuthId, compilerId, packerId);
+        String compilerName = appConfigUpdateDto.getCompilerConfig();
+        String packerName = appConfigUpdateDto.getPackerConfig();
+        BuildConfig buildConfig = buildConfigChecker.checkAndGet(compilerName, packerName);
         appConfig.update(appConfigUpdateDto, buildConfig);
         appBuildRepository.update(appConfig);
         return Result.result(ResultStatus.SUCCESS);

+ 14 - 0
mgr/src/main/java/cn/reghao/devops/mgr/ops/build/service/BuildConfigChecker.java

@@ -56,4 +56,18 @@ public class BuildConfigChecker {
 
         return new BuildConfig(repoAuthConfig, compilerConfig, packerConfig);
     }
+
+    public BuildConfig checkAndGet(String compilerName, String packerName) {
+        CompilerConfig compilerConfig = compilerConfigRepository.findByName(compilerName);
+        if (compilerConfig == null) {
+            throw new RuntimeException("编译器配置不存在");
+        }
+
+        PackerConfig packerConfig = packerConfigRepository.findByName(packerName);
+        if (packerConfig == null) {
+            throw new RuntimeException("打包配置不存在");
+        }
+
+        return new BuildConfig(null, compilerConfig, packerConfig);
+    }
 }