Ver código fonte

update web.mgr.builds package

reghao 1 ano atrás
pai
commit
f639c2f773

+ 1 - 2
web/src/main/java/cn/reghao/devops/web/mgr/app/service/impl/AppBuildServiceImpl.java

@@ -17,8 +17,7 @@ import cn.reghao.devops.web.mgr.build.model.AppDto;
 import cn.reghao.devops.web.mgr.build.model.LocalBuildDir;
 import cn.reghao.devops.web.mgr.build.model.constant.RepoType;
 import cn.reghao.devops.web.mgr.builds.model.vo.BuildConfig;
-import cn.reghao.devops.web.mgr.builds.service.impl.BuildConfigChecker;
-import cn.reghao.jutil.jdk.converter.DateTimeConverter;
+import cn.reghao.devops.web.mgr.builds.service.BuildConfigChecker;
 import cn.reghao.jutil.jdk.result.Result;
 import cn.reghao.jutil.jdk.result.ResultStatus;
 import lombok.extern.slf4j.Slf4j;

+ 4 - 4
web/src/main/java/cn/reghao/devops/web/mgr/builds/controller/CompilerConfigController.java

@@ -28,15 +28,15 @@ public class CompilerConfigController {
 
     @ApiOperation(value = "添加/修改应用编译配置")
     @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
-    public String addOrModifyCompileConfig(@Validated CompilerConfig compilerConfig) {
-        Result result = compilerConfigService.addOrModify(compilerConfig);
+    public String addOrUpdateCompileConfig(@Validated CompilerConfig compilerConfig) {
+        Result result = compilerConfigService.addOrUpdate(compilerConfig);
         return WebResult.result(result);
     }
 
     @ApiOperation(value = "删除应用编译配置")
     @DeleteMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String deleteCompileConfig(@PathVariable("id") CompilerConfig compilerConfig) {
-        Result result = compilerConfigService.delete(compilerConfig);
+    public String deleteCompileConfig(@PathVariable("id") int id) {
+        Result result = compilerConfigService.delete(id);
         return WebResult.result(result);
     }
 }

+ 2 - 2
web/src/main/java/cn/reghao/devops/web/mgr/builds/controller/DockerRegistryController.java

@@ -27,8 +27,8 @@ public class DockerRegistryController {
 
     @ApiOperation(value = "添加/修改 DockerRegistry 配置")
     @PostMapping(value = "/registry", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String addOrModifyRepoConfig(@Validated DockerAuth dockerAuth) {
-        dockerRegistryService.addOrModify(dockerAuth);
+    public String addOrUpdateRepoConfig(@Validated DockerAuth dockerAuth) {
+        dockerRegistryService.addOrUpdate(dockerAuth);
         return WebResult.success();
     }
 

+ 4 - 4
web/src/main/java/cn/reghao/devops/web/mgr/builds/controller/PackerConfigController.java

@@ -28,15 +28,15 @@ public class PackerConfigController {
 
     @ApiOperation(value = "添加/修改应用打包配置")
     @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
-    public String addOrModifyPackConfig(@Validated PackerConfig packerConfig) {
-        Result result = packerConfigService.addOrModify(packerConfig);
+    public String addOrUpdatePackConfig(@Validated PackerConfig packerConfig) {
+        Result result = packerConfigService.addOrUpdate(packerConfig);
         return WebResult.result(result);
     }
 
     @ApiOperation(value = "删除应用打包配置")
     @DeleteMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String deletePackConfig(@PathVariable("id") PackerConfig packerConfig) {
-        Result result = packerConfigService.delete(packerConfig);
+    public String deletePackConfig(@PathVariable("id")  int id) {
+        Result result = packerConfigService.delete(id);
         return WebResult.result(result);
     }
 }

+ 4 - 4
web/src/main/java/cn/reghao/devops/web/mgr/builds/controller/RepoAuthConfigController.java

@@ -28,15 +28,15 @@ public class RepoAuthConfigController {
 
     @ApiOperation(value = "添加/修改仓库认证配置")
     @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
-    public String addOrModifyRepoConfig(@Validated RepoAuthConfig repoAuth) {
-        Result result = repoAuthConfigService.addOrModify(repoAuth);
+    public String addOrUpdateRepoConfig(@Validated RepoAuthConfig repoAuth) {
+        Result result = repoAuthConfigService.addOrUpdate(repoAuth);
         return WebResult.result(result);
     }
 
     @ApiOperation(value = "删除仓库认证配置")
     @DeleteMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String deleteRepoConfig(@PathVariable("id") RepoAuthConfig repoAuth) {
-        Result result = repoAuthConfigService.delete(repoAuth);
+    public String deleteRepoConfig(@PathVariable("id") int id) {
+        Result result = repoAuthConfigService.delete(id);
         return WebResult.result(result);
     }
 }

+ 1 - 1
web/src/main/java/cn/reghao/devops/web/mgr/builds/service/impl/BuildConfigChecker.java → web/src/main/java/cn/reghao/devops/web/mgr/builds/service/BuildConfigChecker.java

@@ -1,4 +1,4 @@
-package cn.reghao.devops.web.mgr.builds.service.impl;
+package cn.reghao.devops.web.mgr.builds.service;
 
 import cn.reghao.devops.web.mgr.builds.db.repository.CompilerConfigRepository;
 import cn.reghao.devops.web.mgr.builds.db.repository.PackerConfigRepository;

+ 2 - 2
web/src/main/java/cn/reghao/devops/web/mgr/builds/service/CompilerConfigService.java

@@ -8,6 +8,6 @@ import cn.reghao.jutil.jdk.result.Result;
  * @date 2021-09-17 15:54:07
  */
 public interface CompilerConfigService {
-    Result addOrModify(CompilerConfig compilerConfig);
-    Result delete(CompilerConfig compilerConfig);
+    Result addOrUpdate(CompilerConfig compilerConfig);
+    Result delete(int id);
 }

+ 4 - 31
web/src/main/java/cn/reghao/devops/web/mgr/builds/service/DockerRegistryService.java

@@ -1,40 +1,13 @@
 package cn.reghao.devops.web.mgr.builds.service;
 
-import cn.reghao.devops.common.docker.DockerImpl;
 import cn.reghao.devops.common.docker.model.DockerAuth;
-import cn.reghao.devops.web.mgr.builds.db.repository.DockerRegistryRepository;
-import cn.reghao.devops.web.mgr.builds.model.po.DockerRegistry;
-import org.springframework.stereotype.Service;
+import cn.reghao.jutil.jdk.result.Result;
 
 /**
  * @author reghao
  * @date 2024-07-26 19:16:57
  */
-@Service
-public class DockerRegistryService {
-    private final DockerRegistryRepository dockerAuthRepository;
-
-    public DockerRegistryService(DockerRegistryRepository dockerAuthRepository) {
-        this.dockerAuthRepository = dockerAuthRepository;
-    }
-
-    public void addOrModify(DockerAuth dockerAuth) {
-        DockerImpl docker = new DockerImpl(dockerAuth);
-        docker.auth();
-
-        String registryUrl = dockerAuth.getRegistryUrl();
-        DockerRegistry dockerRegistry = dockerAuthRepository.findByRegistryUrl(registryUrl);
-        if (dockerRegistry == null) {
-            dockerRegistry = new DockerRegistry(dockerAuth);
-        } else {
-            dockerRegistry.setUsername(dockerAuth.getUsername());
-            dockerRegistry.setPassword(dockerAuth.getPassword());
-        }
-
-        dockerAuthRepository.save(dockerRegistry);
-    }
-
-    public void delete(Integer id) {
-        dockerAuthRepository.deleteById(id);
-    }
+public interface DockerRegistryService {
+    void addOrUpdate(DockerAuth dockerAuth);
+    Result delete(int id);
 }

+ 2 - 2
web/src/main/java/cn/reghao/devops/web/mgr/builds/service/PackerConfigService.java

@@ -8,6 +8,6 @@ import cn.reghao.jutil.jdk.result.Result;
  * @date 2021-09-17 15:54:16
  */
 public interface PackerConfigService {
-    Result addOrModify(PackerConfig packerConfig);
-    Result delete(PackerConfig packerConfig);
+    Result addOrUpdate(PackerConfig packerConfig);
+    Result delete(int id);
 }

+ 2 - 2
web/src/main/java/cn/reghao/devops/web/mgr/builds/service/RepoAuthConfigService.java

@@ -8,6 +8,6 @@ import cn.reghao.jutil.jdk.result.Result;
  * @date 2021-09-17 10:16:07
  */
 public interface RepoAuthConfigService {
-    Result addOrModify(RepoAuthConfig repoAuthConfig);
-    Result delete(RepoAuthConfig repoAuthConfig);
+    Result addOrUpdate(RepoAuthConfig repoAuthConfig);
+    Result delete(int id);
 }

+ 8 - 4
web/src/main/java/cn/reghao/devops/web/mgr/builds/service/impl/CompilerConfigServiceImpl.java

@@ -28,7 +28,7 @@ public class CompilerConfigServiceImpl implements CompilerConfigService {
     }
 
     @Override
-    public Result addOrModify(CompilerConfig compilerConfig) {
+    public Result addOrUpdate(CompilerConfig compilerConfig) {
         String name = compilerConfig.getName();
         CompilerConfig entity = compilerConfigRepository.findByName(name);
         if (entity == null) {
@@ -51,9 +51,13 @@ public class CompilerConfigServiceImpl implements CompilerConfigService {
     }
 
     @Override
-    public Result delete(CompilerConfig compilerConfig) {
-        compilerConfigRepository.delete(compilerConfig);
-        BuildTools.removeCodeCompiler(compilerConfig.getName());
+    public Result delete(int id) {
+        CompilerConfig compilerConfig = compilerConfigRepository.findById(id).orElse(null);
+        if (compilerConfig != null) {
+            BuildTools.removeCodeCompiler(compilerConfig.getName());
+            compilerConfigRepository.deleteById(id);
+        }
+
         return Result.result(ResultStatus.SUCCESS);
     }
 

+ 46 - 0
web/src/main/java/cn/reghao/devops/web/mgr/builds/service/impl/DockerRegistryServiceImpl.java

@@ -0,0 +1,46 @@
+package cn.reghao.devops.web.mgr.builds.service.impl;
+
+import cn.reghao.devops.common.docker.DockerImpl;
+import cn.reghao.devops.common.docker.model.DockerAuth;
+import cn.reghao.devops.web.mgr.builds.db.repository.DockerRegistryRepository;
+import cn.reghao.devops.web.mgr.builds.model.po.DockerRegistry;
+import cn.reghao.devops.web.mgr.builds.service.DockerRegistryService;
+import cn.reghao.jutil.jdk.result.Result;
+import cn.reghao.jutil.jdk.result.ResultStatus;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author reghao
+ * @date 2024-07-26 19:16:57
+ */
+@Service
+public class DockerRegistryServiceImpl implements DockerRegistryService {
+    private final DockerRegistryRepository dockerAuthRepository;
+
+    public DockerRegistryServiceImpl(DockerRegistryRepository dockerAuthRepository) {
+        this.dockerAuthRepository = dockerAuthRepository;
+    }
+
+    @Override
+    public void addOrUpdate(DockerAuth dockerAuth) {
+        DockerImpl docker = new DockerImpl(dockerAuth);
+        docker.auth();
+
+        String registryUrl = dockerAuth.getRegistryUrl();
+        DockerRegistry dockerRegistry = dockerAuthRepository.findByRegistryUrl(registryUrl);
+        if (dockerRegistry == null) {
+            dockerRegistry = new DockerRegistry(dockerAuth);
+        } else {
+            dockerRegistry.setUsername(dockerAuth.getUsername());
+            dockerRegistry.setPassword(dockerAuth.getPassword());
+        }
+
+        dockerAuthRepository.save(dockerRegistry);
+    }
+
+    @Override
+    public Result delete(int id) {
+        dockerAuthRepository.deleteById(id);
+        return Result.result(ResultStatus.SUCCESS);
+    }
+}

+ 8 - 4
web/src/main/java/cn/reghao/devops/web/mgr/builds/service/impl/PackerConfigServiceImpl.java

@@ -26,7 +26,7 @@ public class PackerConfigServiceImpl implements PackerConfigService {
     }
 
     @Override
-    public Result addOrModify(PackerConfig packerConfig) {
+    public Result addOrUpdate(PackerConfig packerConfig) {
         String type = packerConfig.getType();
         if (type.equals(PackType.zip.getName())) {
             packerConfig.setTargetPath("/");
@@ -51,9 +51,13 @@ public class PackerConfigServiceImpl implements PackerConfigService {
     }
 
     @Override
-    public Result delete(PackerConfig packerConfig) {
-        packerConfigRepository.delete(packerConfig);
-        BuildTools.removeCodePacker(packerConfig.getName());
+    public Result delete(int id) {
+        PackerConfig packerConfig = packerConfigRepository.findById(id).orElse(null);
+        if (packerConfig != null) {
+            BuildTools.removeCodePacker(packerConfig.getName());
+            packerConfigRepository.deleteById(id);
+        }
+
         return Result.result(ResultStatus.SUCCESS);
     }
 }

+ 8 - 4
web/src/main/java/cn/reghao/devops/web/mgr/builds/service/impl/RepoAuthConfigServiceImpl.java

@@ -24,7 +24,7 @@ public class RepoAuthConfigServiceImpl implements RepoAuthConfigService {
     }
 
     @Override
-    public Result addOrModify(RepoAuthConfig repoAuthConfig) {
+    public Result addOrUpdate(RepoAuthConfig repoAuthConfig) {
         String name = repoAuthConfig.getName();
         RepoAuthConfig entity = repoAuthConfigRepository.findByName(name);
         if (entity == null) {
@@ -54,9 +54,13 @@ public class RepoAuthConfigServiceImpl implements RepoAuthConfigService {
     }
 
     @Override
-    public Result delete(RepoAuthConfig repoAuthConfig) {
-        repoAuthConfigRepository.delete(repoAuthConfig);
-        BuildTools.removeCodeUpdater(repoAuthConfig.getName());
+    public Result delete(int id) {
+        RepoAuthConfig repoAuthConfig = repoAuthConfigRepository.findById(id).orElse(null);
+        if (repoAuthConfig != null) {
+            BuildTools.removeCodeUpdater(repoAuthConfig.getName());
+            repoAuthConfigRepository.deleteById(id);
+        }
+
         return Result.result(ResultStatus.SUCCESS);
     }
 }