Просмотр исходного кода

优化 app 模块的代码结构

reghao 4 лет назад
Родитель
Сommit
5df88ae4f8
68 измененных файлов с 1179 добавлено и 388 удалено
  1. 6 6
      common/src/main/java/cn/reghao/autodop/common/docker/Docker.java
  2. 2 2
      common/src/main/java/cn/reghao/autodop/common/docker/unixdomain/UnixSocketClient.java
  3. 2 2
      common/src/main/java/cn/reghao/autodop/common/machine/cpu/Cpu.java
  4. 2 2
      common/src/main/java/cn/reghao/autodop/common/machine/os/Os.java
  5. 11 9
      common/src/main/java/cn/reghao/autodop/common/mqtt/DefaultMqttClient.java
  6. 1 1
      common/src/main/java/cn/reghao/autodop/common/util/ByteConverter.java
  7. 1 1
      common/src/main/java/cn/reghao/autodop/common/util/FileOps.java
  8. 4 4
      common/src/main/java/cn/reghao/autodop/common/util/compression/ZipFiles.java
  9. 2 2
      common/src/main/java/cn/reghao/autodop/common/util/thread/ThreadFactoryBuilder.java
  10. 1 1
      dagent/src/main/java/cn/reghao/autodop/dagent/app/ZipAppServiceImpl.java
  11. 3 1
      dagent/src/main/java/cn/reghao/autodop/dagent/rpc/RpcListener.java
  12. 1 1
      dagent/src/main/java/cn/reghao/autodop/dagent/spring/DagentLifecycle.java
  13. 9 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/BuildDeployController.java
  14. 24 25
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/config/AppConfigController.java
  15. 8 8
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/config/BuildDirController.java
  16. 10 11
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/config/CompilerConfigController.java
  17. 10 9
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/config/PackerConfigController.java
  18. 13 15
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/config/ProjConfigController.java
  19. 10 12
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/config/RepoAuthConfigController.java
  20. 5 5
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/page/AppConfigPageController.java
  21. 5 5
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/page/ProjConfigPageController.java
  22. 5 5
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/page/RepoAuthPageController.java
  23. 5 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/crud/config/AppConfigCrud.java
  24. 2 70
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/crud/config/BuildDirCrud.java
  25. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/crud/config/ProjConfigCrud.java
  26. 2 77
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/crud/config/RepoAuthConfigCrud.java
  27. 9 9
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/crud/config/SharedEntityChecker.java
  28. 40 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/crud/config/impl/BuildDirCrudImpl.java
  29. 105 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/crud/config/impl/RepoAuthConfigCrudImpl.java
  30. 4 12
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/query/config/BuildDirQuery.java
  31. 15 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/query/config/RepoAuthConfigQuery.java
  32. 31 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/query/config/impl/BuildDirQueryImpl.java
  33. 10 8
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/query/config/impl/RepoAuthConfigQueryImpl.java
  34. 4 4
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/po/config/build/BuildDirLocal.java
  35. 6 4
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/AppStatusService.java
  36. 5 5
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/BuildDeployDispatcher.java
  37. 1 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/BuildDeployService.java
  38. 13 2
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppDeployer.java
  39. 2 2
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppIntegrate.java
  40. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/tools/compiler/MavenCompiler.java
  41. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/tools/packer/ZipPack.java
  42. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/tools/repo/GitImpl.java
  43. 9 3
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/AppConfigService.java
  44. 0 23
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/AppConfigServiceImpl.java
  45. 6 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/BuildDirService.java
  46. 6 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/CompilerConfigService.java
  47. 6 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/PackerConfigService.java
  48. 8 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/ProjConfigService.java
  49. 7 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/RepoAuthConfigService.java
  50. 238 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/AppConfigServiceImpl.java
  51. 80 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/BuildDirServiceImpl.java
  52. 97 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/CompilerConfigServiceImpl.java
  53. 59 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/PackerConfigServiceImpl.java
  54. 115 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/ProjConfigServiceImpl.java
  55. 109 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/RepoAuthConfigServiceImpl.java
  56. 10 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/impl/BuildDeployServiceImpl.java
  57. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/machine/service/ssh/WebSshImpl.java
  58. 5 5
      dmaster/src/main/java/cn/reghao/autodop/dmaster/machine/service/ssh/ws/WebSocketHandlerImpl.java
  59. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/monitor/service/MonitorScheduler.java
  60. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/mqttsub/MessageListener.java
  61. 6 6
      dmaster/src/main/java/cn/reghao/autodop/dmaster/notification/service/NotifyService.java
  62. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/rbac/service/MenuServiceImpl.java
  63. 5 5
      dmaster/src/main/java/cn/reghao/autodop/dmaster/rbac/service/UserServiceImpl.java
  64. 2 2
      dmaster/src/main/java/cn/reghao/autodop/dmaster/spring/BeforeAppShutdown.java
  65. 10 9
      dmaster/src/main/java/cn/reghao/autodop/dmaster/spring/DmasterLifecycle.java
  66. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/spring/SpringBootUtil.java
  67. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/spring/interceptor/AppIntegrateReinitInterceptor.java
  68. 2 2
      dmaster/src/main/java/cn/reghao/autodop/dmaster/util/AliOss.java

+ 6 - 6
common/src/main/java/cn/reghao/autodop/common/docker/Docker.java

@@ -68,7 +68,7 @@ public class Docker implements ImageOps, ContainerOps, AutoCloseable {
             }
             return result;
         } else {
-            throw new DockerException("Docker 响应是 NULL...");
+            throw new DockerException("Docker 响应是 NULL");
         }
     }
 
@@ -173,7 +173,7 @@ public class Docker implements ImageOps, ContainerOps, AutoCloseable {
             if (response != null) {
                 return response.content().toString(StandardCharsets.UTF_8);
             } else {
-                throw new DockerException("请求 " + uri + " 的响应是 NULL...");
+                throw new DockerException("请求 " + uri + " 的响应是 NULL");
             }
         } catch (IOException | InterruptedException e) {
             throw new DockerException(ExceptionUtil.errorMsg(e));
@@ -231,7 +231,7 @@ public class Docker implements ImageOps, ContainerOps, AutoCloseable {
         } catch (IOException | InterruptedException e) {
             throw new DockerException(ExceptionUtil.errorMsg(e));
         }
-        throw new DockerException("请求 " + uri + " 创建容器失败...");
+        throw new DockerException("请求 " + uri + " 创建容器失败");
     }
 
     @Override
@@ -300,7 +300,7 @@ public class Docker implements ImageOps, ContainerOps, AutoCloseable {
                         String stdout = response.content().toString(StandardCharsets.UTF_8);
                         return Arrays.asList(stdout.split(System.lineSeparator()));
                     } else {
-                        throw new DockerException("请求 " + uri + " 的响应是 NULL...");
+                        throw new DockerException("请求 " + uri + " 的响应是 NULL");
                     }
                 case error:
                     // 标准错误
@@ -310,7 +310,7 @@ public class Docker implements ImageOps, ContainerOps, AutoCloseable {
                         String stderr = response.content().toString(StandardCharsets.UTF_8);
                         return Arrays.asList(stderr.split(System.lineSeparator()));
                     } else {
-                        throw new DockerException("请求 " + uri + " 的响应是 NULL...");
+                        throw new DockerException("请求 " + uri + " 的响应是 NULL");
                     }
                 default:
                     throw new DockerException("日志级别 " + logLevel + " 不存在");
@@ -393,7 +393,7 @@ public class Docker implements ImageOps, ContainerOps, AutoCloseable {
                 String result =  response.content().toString(StandardCharsets.UTF_8);
                 return JsonConverter.jsonToObject(result, ContainerInfo.class);
             } else {
-                throw new DockerException("请求 " + uri + " 的响应是 NULL...");
+                throw new DockerException("请求 " + uri + " 的响应是 NULL");
             }
         } catch (IOException | InterruptedException e) {
             throw new DockerException(ExceptionUtil.errorMsg(e));

+ 2 - 2
common/src/main/java/cn/reghao/autodop/common/docker/unixdomain/UnixSocketClient.java

@@ -54,7 +54,7 @@ public class UnixSocketClient {
                log.info("已连接到 Unix Socket");
                channel = channelFuture.channel();
            } else {
-               log.error("Unix Socket 连接失败, 检查 " + DEFAULT_UNIX_ENDPOINT + " 是否存在...");
+               log.error("Unix Socket 连接失败, 检查 " + DEFAULT_UNIX_ENDPOINT + " 是否存在");
            }
         });
 
@@ -76,7 +76,7 @@ public class UnixSocketClient {
         /*
         错误用法,忽略了异步的本质
         if (channel == null) {
-            throw new IOException("Unix Socket 连接失败, 检查 " + DEFAULT_UNIX_ENDPOINT + " 是否存在...");
+            throw new IOException("Unix Socket 连接失败, 检查 " + DEFAULT_UNIX_ENDPOINT + " 是否存在");
         }*/
 
         ChannelPromise promise = clientHandler.sendRequest(request);

+ 2 - 2
common/src/main/java/cn/reghao/autodop/common/machine/cpu/Cpu.java

@@ -27,7 +27,7 @@ public class Cpu {
     public CpuInfo info() {
         List<String> list = textFile.read(LinuxProc.CPU_INFO);
         if (list.isEmpty()) {
-            log.error("CPU 信息获取失败...");
+            log.error("CPU 信息获取失败");
             return null;
         }
 
@@ -46,7 +46,7 @@ public class Cpu {
         }
 
         if (result.isEmpty()) {
-            log.error("CPU 信息获取失败...");
+            log.error("CPU 信息获取失败");
             return null;
         }
 

+ 2 - 2
common/src/main/java/cn/reghao/autodop/common/machine/os/Os.java

@@ -44,7 +44,7 @@ public class Os {
         String loadAvg = textFile.readFile(LinuxProc.LOAD_AVG);
         String[] strs = loadAvg.split("\\s+");
         if (strs.length != 5) {
-            log.error("解析 " + LinuxProc.LOAD_AVG + " 文件错误...");
+            log.error("解析 " + LinuxProc.LOAD_AVG + " 文件错误");
             return null;
         }
 
@@ -55,7 +55,7 @@ public class Os {
 
         String[] procs = strs[3].split("/");
         if (procs.length != 2) {
-            log.error("解析 " + LinuxProc.LOAD_AVG + " 文件错误...");
+            log.error("解析 " + LinuxProc.LOAD_AVG + " 文件错误");
             return null;
         }
 

+ 11 - 9
common/src/main/java/cn/reghao/autodop/common/mqtt/DefaultMqttClient.java

@@ -1,6 +1,8 @@
 package cn.reghao.autodop.common.mqtt;
 
 import cn.reghao.autodop.common.message.AsyncMsg;
+import cn.reghao.autodop.common.msg.Message;
+import cn.reghao.autodop.common.msg.rpc.RpcMsg;
 import cn.reghao.jdkutil.MachineId;
 import cn.reghao.jdkutil.serializer.JsonConverter;
 import lombok.extern.slf4j.Slf4j;
@@ -22,7 +24,7 @@ public class DefaultMqttClient implements AutoCloseable {
     private final MosquittoProperties properties;
     private final MqttClient client;
     // 记录需要返回结果的 pub 消息, size 为 0 时表示所有 pub 消息的结果都已 sub
-    private final Map<String, AsyncMsg> pubSubRecorder = new HashMap<>();
+    private final Map<String, RpcMsg> pubSubRecorder = new HashMap<>();
     private final Map<String, IMqttMessageListener> subMap = new HashMap<>();
     private final MqttCallback callback = new MqttClientCallback();
 
@@ -51,8 +53,8 @@ public class DefaultMqttClient implements AutoCloseable {
         client.close();
     }
 
-    public void putRecord(String msgId, AsyncMsg asyncMsg) {
-        pubSubRecorder.put(msgId, asyncMsg);
+    public void putRecord(String msgId, RpcMsg rpcMsg) {
+        pubSubRecorder.put(msgId, rpcMsg);
     }
 
     public void removeRecord(String msgId) {
@@ -115,14 +117,14 @@ public class DefaultMqttClient implements AutoCloseable {
      * @return
      * @date 2021-06-30 上午11:22
      */
-    public void pubWithResult(String topic, int qos, AsyncMsg asyncMsg) throws MqttException {
-        MqttMessage message = new MqttMessage();
-        message.setQos(qos);
-        message.setPayload(JsonConverter.objectToJson(asyncMsg).getBytes());
+    public void pubWithResult(String topic, int qos, Message message) throws MqttException {
+        MqttMessage mqttMessage = new MqttMessage();
+        mqttMessage.setQos(qos);
+        mqttMessage.setPayload(JsonConverter.objectToJson(message).getBytes());
 
         connect();
-        client.publish(topic, message);
-        pubSubRecorder.put(asyncMsg.getMsgId(), asyncMsg);
+        client.publish(topic, mqttMessage);
+        pubSubRecorder.put(message.getRpcMsg().getMsgId(), message.getRpcMsg());
     }
 
     class MqttClientCallback implements MqttCallbackExtended {

+ 1 - 1
common/src/main/java/cn/reghao/autodop/common/util/ByteConverter.java

@@ -33,7 +33,7 @@ public class ByteConverter {
         if (value < base) {
             return value + "PiB";
         } else {
-            return "data too large...";
+            return "data too large";
         }
     }
 

+ 1 - 1
common/src/main/java/cn/reghao/autodop/common/util/FileOps.java

@@ -129,7 +129,7 @@ public class FileOps {
 
                 @Override
                 public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
-                    log.info("无法查看 {} ...", file.toString());
+                    log.info("无法查看 {} ", file.toString());
                     return FileVisitResult.CONTINUE;
                 }
 

+ 4 - 4
common/src/main/java/cn/reghao/autodop/common/util/compression/ZipFiles.java

@@ -28,7 +28,7 @@ public class ZipFiles {
         // TODO: 判断 dst 是否为 src 的子目录
         File srcFile = new File(src);
         if (!srcFile.exists()) {
-            log.info("{} 不存在...", src);
+            log.info("{} 不存在", src);
             return;
         }
 
@@ -41,7 +41,7 @@ public class ZipFiles {
 
         File dstFile = new File(filePath);
         if (dstFile.exists() && !dstFile.delete()) {
-            log.info("删除 {} 失败...", dst);
+            log.info("删除 {} 失败", dst);
             return;
         }
 
@@ -68,7 +68,7 @@ public class ZipFiles {
 
         File dstFile = new File(filePath);
         if (dstFile.exists() && !dstFile.delete()) {
-            log.info("删除 {} 失败...", dst);
+            log.info("删除 {} 失败", dst);
             return;
         }
 
@@ -139,7 +139,7 @@ public class ZipFiles {
     public static void unzip(String src, String dst) throws IOException {
         File file = new File(src);
         if (!file.exists()) {
-            log.info("{} 不存在...", src);
+            log.info("{} 不存在", src);
             return;
         }
 

+ 2 - 2
common/src/main/java/cn/reghao/autodop/common/util/thread/ThreadFactoryBuilder.java

@@ -27,7 +27,7 @@ public class ThreadFactoryBuilder {
      * Sets the naming format to use when naming threads ({@link Thread#setName}) which are created
      * with this ThreadFactory.
      *
-     * @param nameFormat a {@link String#format(String, Object...)}-compatible format String, to which
+     * @param nameFormat a {@link String#format(String, Object)}-compatible format String, to which
      *     a unique integer (0, 1, etc.) will be supplied as the single parameter. This integer will
      *     be unique to the built instance of the ThreadFactory and will be assigned sequentially. For
      *     example, {@code "rpc-pool-%d"} will generate thread names like {@code "rpc-pool-0"},
@@ -134,7 +134,7 @@ public class ThreadFactoryBuilder {
         };
     }
 
-    private static String format(String format, Object... args) {
+    private static String format(String format, Object args) {
         return String.format(Locale.ROOT, format, args);
     }
 }

+ 1 - 1
dagent/src/main/java/cn/reghao/autodop/dagent/app/ZipAppServiceImpl.java

@@ -17,7 +17,7 @@ import java.util.List;
 public class ZipAppServiceImpl implements AppService {
     @Override
     public AppStatus deploy(DeployParam deployParam) {
-        log.info("zip 部署...");
+        log.info("zip 部署");
         return null;
     }
 

+ 3 - 1
dagent/src/main/java/cn/reghao/autodop/dagent/rpc/RpcListener.java

@@ -2,6 +2,7 @@ package cn.reghao.autodop.dagent.rpc;
 
 import cn.reghao.autodop.common.mqtt.DefaultMqttClient;
 import cn.reghao.autodop.common.msg.Message;
+import cn.reghao.autodop.common.msg.MsgQueue;
 import cn.reghao.autodop.common.msg.rpc.RpcPayload;
 import cn.reghao.autodop.common.msg.rpc.RpcMsg;
 import cn.reghao.autodop.common.msg.rpc.RpcResult;
@@ -79,7 +80,8 @@ public class RpcListener implements MqttCallback {
     }
 
     private void rpcReply(Message message) throws MqttException {
-        mqttClient.pub(message.getDestination(), 1, JsonConverter.objectToJson(message));
+        String topic = MsgQueue.dmasterTopic();
+        mqttClient.pub(topic, 1, JsonConverter.objectToJson(message));
     }
 
     @Override

+ 1 - 1
dagent/src/main/java/cn/reghao/autodop/dagent/spring/DagentLifecycle.java

@@ -74,6 +74,6 @@ public class DagentLifecycle implements ApplicationRunner, DisposableBean {
 
     private void pubDagentShutdown() {
         nodeClazzPub.nodeShutdown();
-        log.info("Dagent 停止...");
+        log.info("Dagent 停止");
     }
 }

+ 9 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/BuildDeployController.java

@@ -1,5 +1,6 @@
 package cn.reghao.autodop.dmaster.app.controller;
 
+import cn.reghao.autodop.dmaster.app.service.BuildDeployService;
 import cn.reghao.jdkutil.result.WebBody;
 import cn.reghao.autodop.dmaster.app.service.AppBuildDeployService;
 import cn.reghao.autodop.dmaster.app.service.BuildDeployDispatcher;
@@ -20,10 +21,14 @@ import org.springframework.web.bind.annotation.*;
 @RestController
 @RequestMapping("/api/app/bd")
 public class BuildDeployController {
+    private final BuildDeployService buildDeployService;
+
     private final BuildDeployDispatcher buildDeployDispatcher;
     private final AppBuildDeployService buildService;
 
-    public BuildDeployController(BuildDeployDispatcher buildDeployDispatcher, AppBuildDeployService buildService) {
+    public BuildDeployController(BuildDeployService buildDeployService,
+                                 BuildDeployDispatcher buildDeployDispatcher, AppBuildDeployService buildService) {
+        this.buildDeployService = buildDeployService;
         this.buildDeployDispatcher = buildDeployDispatcher;
         this.buildService = buildService;
     }
@@ -32,6 +37,7 @@ public class BuildDeployController {
     @ApiImplicitParams(@ApiImplicitParam(name="appId", value="应用 ID", paramType="query", dataType = "String"))
     @PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
     public String buildAndDeploy(@RequestParam("appId") String appId) throws Exception {
+        //buildDeployService.buildAndDeploy(appId);
         String ret = buildDeployDispatcher.buildAndDeploy(appId, true);
         return WebBody.successWithMsg(ret);
     }
@@ -40,6 +46,7 @@ public class BuildDeployController {
     @ApiImplicitParams(@ApiImplicitParam(name="appId", value="应用 ID", paramType="query", dataType = "String"))
     @PostMapping(value = "/build", produces = MediaType.APPLICATION_JSON_VALUE)
     public String build(@RequestParam("appId") String appId) throws Exception {
+        //buildDeployService.build(appId);
         String ret = buildDeployDispatcher.buildAndDeploy(appId, false);
         return WebBody.successWithMsg(ret);
     }
@@ -51,6 +58,7 @@ public class BuildDeployController {
     })
     @PostMapping(value = "/deploy", produces = MediaType.APPLICATION_JSON_VALUE)
     public String deploy(@RequestParam("appId") String appId, @RequestParam("commitId") String commitId) {
+        //buildDeployService.deploy(appId, commitId);
         buildDeployDispatcher.deploy(appId, commitId);
         return WebBody.success();
     }

+ 24 - 25
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/config/AppConfigController.java

@@ -2,19 +2,18 @@ package cn.reghao.autodop.dmaster.app.controller.config;
 
 import cn.reghao.autodop.dmaster.app.model.dto.DeployConfigs;
 import cn.reghao.autodop.dmaster.app.model.po.config.build.PackerConfig;
+import cn.reghao.autodop.dmaster.app.service.config.AppConfigService;
 import cn.reghao.autodop.dmaster.machine.db.query.MachineHostQuery;
 import cn.reghao.jdkutil.result.Result;
 import cn.reghao.jdkutil.result.ResultStatus;
 import cn.reghao.autodop.dmaster.app.model.vo.NewApp;
 import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
 import cn.reghao.autodop.dmaster.notification.model.po.NotifyGroup;
-import cn.reghao.autodop.dmaster.app.db.crud.config.AppConfigCrud;
 import cn.reghao.jdkutil.result.WebBody;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -29,64 +28,56 @@ import java.util.List;
 @RestController
 @RequestMapping("/api/app/config/app")
 public class AppConfigController {
-    private final AppConfigCrud appConfigCrud;
+    private AppConfigService appConfigService;
     private MachineHostQuery hostQuery;
 
-    public AppConfigController(AppConfigCrud appConfigCrud, MachineHostQuery hostQuery) {
-        this.appConfigCrud = appConfigCrud;
+    public AppConfigController(AppConfigService appConfigService, MachineHostQuery hostQuery) {
+        this.appConfigService = appConfigService;
         this.hostQuery = hostQuery;
     }
 
     /* 应用编排 */
     @ApiOperation(value = "添加/修改应用编排")
     @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
-    public ResponseEntity<String> addAppOrchestration(@Validated AppConfig app) {
+    public String addAppOrchestration(@Validated AppConfig app) {
         Result result;
         try {
             // TODO app 属于 proj 时,提交的数据中 proj 是 null
-            result = appConfigCrud.insertOrUpdate(app);
+            result = appConfigService.add(app);
         } catch (Exception e) {
             String msg = e.getMessage();
             result = Result.result(ResultStatus.ERROR, msg);
         }
-        return ResponseEntity.ok().body(WebBody.result(result));
+        return WebBody.result(result);
     }
 
     // TODO 使用 @PathVariable 注解时会自动填充实体
     @ApiOperation(value = "复制应用编排")
     @PostMapping(value = "/copy/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
-    public ResponseEntity<String> copyAppOrchestration(@PathVariable("id") AppConfig app,
+    public String copyAppOrchestration(@PathVariable("id") AppConfig app,
                                                        @Validated NewApp newApp) {
         Result result;
         try {
-            result = appConfigCrud.copy(app, newApp);
+            result = appConfigService.copy(app, newApp);
         } catch (Exception e) {
             String msg = e.getMessage();
             result = Result.result(ResultStatus.ERROR, msg);
         }
-        return ResponseEntity.ok().body(WebBody.result(result));
+        return WebBody.result(result);
     }
 
     @ApiOperation(value = "设置应用通知")
     @PostMapping(value = "/notify", produces = MediaType.APPLICATION_JSON_VALUE)
-    public ResponseEntity<String> appNotify(@RequestParam("id") AppConfig app,
+    public String appNotify(@RequestParam("id") AppConfig app,
                                             @RequestParam("groupId") List<NotifyGroup> notifyGroups) {
         app.setNotifyGroups(notifyGroups);
-        appConfigCrud.updateNotify(app);
-        return ResponseEntity.ok().body(WebBody.success());
+        //appConfigService.updateNotify(app);
+        return WebBody.success();
     }
 
-    @ApiOperation(value = "删除应用编排")
-    @DeleteMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
-    public ResponseEntity<String> deleteAppOrchestration(@PathVariable("id") AppConfig app) {
-        Result result = appConfigCrud.delete(app);
-        return ResponseEntity.ok().body(WebBody.result(result));
-    }
-
-    @ApiOperation(value = "应用部署配置")
+    @ApiOperation(value = "设置应用部署配置")
     @PostMapping(value = "/deploy", produces = MediaType.APPLICATION_JSON_VALUE)
-    public ResponseEntity<String> appDeploy(@RequestParam("id") AppConfig app,
-                                            @Validated DeployConfigs deployConfigs) {
+    public String appDeploy(@RequestParam("id") AppConfig app, @Validated DeployConfigs deployConfigs) {
         PackerConfig packerConfig = app.getPackerConfig();
         String packType = packerConfig.getType();
         deployConfigs.getDeployConfigs().forEach(deployConfig -> {
@@ -97,6 +88,14 @@ public class AppConfigController {
         });
 
         app.setDeployConfigs(deployConfigs.getDeployConfigs());
-        return ResponseEntity.ok().body(WebBody.success());
+        appConfigService.add(app);
+        return WebBody.success();
+    }
+
+    @ApiOperation(value = "删除应用编排")
+    @DeleteMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String deleteAppOrchestration(@PathVariable("id") AppConfig app) {
+        Result result = appConfigService.delete(app);
+        return WebBody.result(result);
     }
 }

+ 8 - 8
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/config/BuildDirController.java

@@ -1,8 +1,8 @@
 package cn.reghao.autodop.dmaster.app.controller.config;
 
-import cn.reghao.jdkutil.result.Result;
+import cn.reghao.autodop.dmaster.app.service.config.BuildDirService;
 import cn.reghao.autodop.dmaster.app.model.po.config.build.BuildDir;
-import cn.reghao.autodop.dmaster.app.db.crud.config.BuildDirCrud;
+import cn.reghao.jdkutil.result.Result;
 import cn.reghao.jdkutil.result.WebBody;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -21,16 +21,16 @@ import org.springframework.web.bind.annotation.*;
 @RestController
 @RequestMapping("/api/app/config/build/dir")
 public class BuildDirController {
-    private BuildDirCrud buildDirCrud;
+    private final BuildDirService buildDirService;
 
-    public BuildDirController(BuildDirCrud buildDirCrud) {
-        this.buildDirCrud = buildDirCrud;
+    public BuildDirController(BuildDirService buildDirService) {
+        this.buildDirService = buildDirService;
     }
 
     @ApiOperation(value = "迁移构建目录")
     @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
-    public ResponseEntity<String> modifyBuildDir(@Validated BuildDir buildDir) {
-        Result result = buildDirCrud.update(buildDir);
-        return ResponseEntity.ok().body(WebBody.result(result));
+    public String modifyBuildDir(@Validated BuildDir buildDir) {
+        Result result = buildDirService.modify(buildDir);
+        return WebBody.result(result);
     }
 }

+ 10 - 11
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/config/CompilerConfigController.java

@@ -1,14 +1,13 @@
 package cn.reghao.autodop.dmaster.app.controller.config;
 
-import cn.reghao.autodop.dmaster.app.db.crud.config.CompilerConfigCrud;
 import cn.reghao.autodop.dmaster.app.model.po.config.build.CompilerConfig;
+import cn.reghao.autodop.dmaster.app.service.config.CompilerConfigService;
 import cn.reghao.jdkutil.result.Result;
 import cn.reghao.jdkutil.result.WebBody;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -21,23 +20,23 @@ import org.springframework.web.bind.annotation.*;
 @RestController
 @RequestMapping("/api/app/config/build/compiler")
 public class CompilerConfigController {
-    private CompilerConfigCrud compilerCrudService;
+    private CompilerConfigService compilerConfigService;
 
-    public CompilerConfigController(CompilerConfigCrud compilerCrudService) {
-        this.compilerCrudService = compilerCrudService;
+    public CompilerConfigController(CompilerConfigService compilerConfigService) {
+        this.compilerConfigService = compilerConfigService;
     }
 
     @ApiOperation(value = "添加/修改应用编译配置")
     @PostMapping(value = "/compiler", produces = MediaType.APPLICATION_JSON_VALUE)
-    public ResponseEntity<String> addCompileConfig(@Validated CompilerConfig compilerConfig) {
-        Result result = compilerCrudService.insertOrUpdate(compilerConfig);
-        return ResponseEntity.ok().body(WebBody.result(result));
+    public String addCompileConfig(@Validated CompilerConfig compilerConfig) {
+        Result result = compilerConfigService.add(compilerConfig);
+        return WebBody.result(result);
     }
 
     @ApiOperation(value = "删除应用编译配置")
     @DeleteMapping(value = "/compiler/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
-    public ResponseEntity<String> deleteCompileConfig(@PathVariable("id") CompilerConfig compilerConfig) {
-        Result result = compilerCrudService.delete(compilerConfig);
-        return ResponseEntity.ok().body(WebBody.result(result));
+    public String deleteCompileConfig(@PathVariable("id") CompilerConfig compilerConfig) {
+        Result result = compilerConfigService.delete(compilerConfig);
+        return WebBody.result(result);
     }
 }

+ 10 - 9
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/config/PackerConfigController.java

@@ -2,6 +2,7 @@ package cn.reghao.autodop.dmaster.app.controller.config;
 
 import cn.reghao.autodop.dmaster.app.db.crud.config.PackerConfigCrud;
 import cn.reghao.autodop.dmaster.app.model.po.config.build.PackerConfig;
+import cn.reghao.autodop.dmaster.app.service.config.PackerConfigService;
 import cn.reghao.jdkutil.result.Result;
 import cn.reghao.jdkutil.result.WebBody;
 import io.swagger.annotations.Api;
@@ -21,23 +22,23 @@ import org.springframework.web.bind.annotation.*;
 @RestController
 @RequestMapping("/api/app/config/build/packer")
 public class PackerConfigController {
-    private PackerConfigCrud packerCrudService;
+    private PackerConfigService packerConfigService;
 
-    public PackerConfigController(PackerConfigCrud packerCrudService) {
-        this.packerCrudService = packerCrudService;
+    public PackerConfigController(PackerConfigService packerConfigService) {
+        this.packerConfigService = packerConfigService;
     }
 
     @ApiOperation(value = "添加应用打包配置")
     @PostMapping(value = "/packer", produces = MediaType.APPLICATION_JSON_VALUE)
-    public ResponseEntity<String> addPackConfig(@Validated PackerConfig packerConfig) {
-        Result result = packerCrudService.insertOrUpdate(packerConfig);
-        return ResponseEntity.ok().body(WebBody.result(result));
+    public String addPackConfig(@Validated PackerConfig packerConfig) {
+        Result result = packerConfigService.add(packerConfig);
+        return WebBody.result(result);
     }
 
     @ApiOperation(value = "删除应用打包配置")
     @DeleteMapping(value = "/packer/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
-    public ResponseEntity<String> deletePackConfig(@PathVariable("id") PackerConfig packerConfig) {
-        Result result = packerCrudService.delete(packerConfig);
-        return ResponseEntity.ok().body(WebBody.result(result));
+    public String deletePackConfig(@PathVariable("id") PackerConfig packerConfig) {
+        Result result = packerConfigService.delete(packerConfig);
+        return WebBody.result(result);
     }
 }

+ 13 - 15
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/config/ProjConfigController.java

@@ -1,15 +1,14 @@
 package cn.reghao.autodop.dmaster.app.controller.config;
 
-import cn.reghao.autodop.dmaster.app.db.crud.config.ProjConfigCrud;
 import cn.reghao.autodop.dmaster.app.model.po.config.ProjConfig;
 import cn.reghao.autodop.dmaster.app.model.vo.NewApp;
+import cn.reghao.autodop.dmaster.app.service.config.ProjConfigService;
 import cn.reghao.jdkutil.result.Result;
 import cn.reghao.jdkutil.result.WebBody;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -22,32 +21,31 @@ import org.springframework.web.bind.annotation.*;
 @RestController
 @RequestMapping("/api/app/config/proj")
 public class ProjConfigController {
-    private final ProjConfigCrud projConfigCrud;
+    private ProjConfigService projConfigService;
 
-    public ProjConfigController(ProjConfigCrud projConfigCrud) {
-        this.projConfigCrud = projConfigCrud;
+    public ProjConfigController(ProjConfigService projConfigService) {
+        this.projConfigService = projConfigService;
     }
 
     /* 项目编排 */
     @ApiOperation(value = "添加/修改项目编排")
     @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
-    public ResponseEntity<String> addProjOrchestration(@Validated ProjConfig proj) {
-        Result result = projConfigCrud.insertOrUpdate(proj);
-        return ResponseEntity.ok().body(WebBody.result(result));
+    public String addProjOrchestration(@Validated ProjConfig proj) {
+        Result result = projConfigService.add(proj);
+        return WebBody.result(result);
     }
 
     @ApiOperation(value = "复制项目编排")
     @PostMapping(value = "/copy/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
-    public ResponseEntity<String> copyProjOrchestration(@PathVariable("id") ProjConfig proj,
-                                                        @Validated NewApp newApp) {
-        Result result = projConfigCrud.copy(proj, newApp);
-        return ResponseEntity.ok().body(WebBody.result(result));
+    public String copyProjOrchestration(@PathVariable("id") ProjConfig proj, @Validated NewApp newApp) {
+        Result result = projConfigService.copy(proj, newApp);
+        return WebBody.result(result);
     }
 
     @ApiOperation(value = "删除项目编排")
     @DeleteMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
-    public ResponseEntity<String> deleteProjOrchestration(@PathVariable("id") ProjConfig proj) {
-        Result result = projConfigCrud.delete(proj);
-        return ResponseEntity.ok().body(WebBody.result(result));
+    public String deleteProjOrchestration(@PathVariable("id") ProjConfig proj) {
+        Result result = projConfigService.delete(proj);
+        return WebBody.result(result);
     }
 }

+ 10 - 12
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/config/RepoAuthConfigController.java

@@ -1,14 +1,12 @@
 package cn.reghao.autodop.dmaster.app.controller.config;
 
-import cn.reghao.autodop.dmaster.app.db.crud.config.RepoAuthConfigCrud;
 import cn.reghao.autodop.dmaster.app.model.po.config.build.RepoAuthConfig;
-import cn.reghao.jdkutil.result.Result;
+import cn.reghao.autodop.dmaster.app.service.config.RepoAuthConfigService;
 import cn.reghao.jdkutil.result.WebBody;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -21,23 +19,23 @@ import org.springframework.web.bind.annotation.*;
 @RestController
 @RequestMapping("/api/app/config/build/repoauth")
 public class RepoAuthConfigController {
-    private RepoAuthConfigCrud repoAuthCrudService;
+    private RepoAuthConfigService repoAuthConfigService;
 
-    public RepoAuthConfigController(RepoAuthConfigCrud repoAuthCrudService) {
-        this.repoAuthCrudService = repoAuthCrudService;
+    public RepoAuthConfigController(RepoAuthConfigService repoAuthConfigService) {
+        this.repoAuthConfigService = repoAuthConfigService;
     }
 
     @ApiOperation(value = "添加/修改仓库认证配置")
     @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
-    public ResponseEntity<String> addRepoConfig(@Validated RepoAuthConfig repoAuth) {
-        Result result = repoAuthCrudService.insertOrUpdate(repoAuth);
-        return ResponseEntity.ok().body(WebBody.result(result));
+    public String addRepoConfig(@Validated RepoAuthConfig repoAuth) {
+        repoAuthConfigService.add(repoAuth);
+        return WebBody.success();
     }
 
     @ApiOperation(value = "删除仓库认证配置")
     @DeleteMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
-    public ResponseEntity<String> deleteRepoConfig(@PathVariable("id") RepoAuthConfig repoAuth) {
-        Result result = repoAuthCrudService.delete(repoAuth);
-        return ResponseEntity.ok().body(WebBody.result(result));
+    public String deleteRepoConfig(@PathVariable("id") RepoAuthConfig repoAuth) {
+        repoAuthConfigService.delete(repoAuth);
+        return WebBody.success();
     }
 }

+ 5 - 5
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/page/AppConfigPageController.java

@@ -11,7 +11,7 @@ import cn.reghao.autodop.dmaster.app.db.query.config.AppConfigQuery;
 import cn.reghao.autodop.dmaster.app.db.query.config.ProjConfigQuery;
 import cn.reghao.autodop.dmaster.app.db.query.config.CompilerConfigQuery;
 import cn.reghao.autodop.dmaster.app.db.query.config.PackerConfigQuery;
-import cn.reghao.autodop.dmaster.app.db.query.config.RepoAuthQuery;
+import cn.reghao.autodop.dmaster.app.db.query.config.RepoAuthConfigQuery;
 import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
 import cn.reghao.autodop.dmaster.app.model.vo.KeyValue;
 import cn.reghao.autodop.dmaster.notification.db.repository.NotifyGroupRepository;
@@ -41,18 +41,18 @@ import java.util.stream.Collectors;
 public class AppConfigPageController {
     private final AppConfigQuery appConfigQuery;
     private final ProjConfigQuery projConfigQuery;
-    private final RepoAuthQuery repoAuthQuery;
+    private final RepoAuthConfigQuery repoAuthConfigQuery;
     private final CompilerConfigQuery compilerConfigQuery;
     private final PackerConfigQuery packerConfigQuery;
     private final MachineHostQuery hostQuery;
     private final NotifyGroupRepository receiverRepository;
 
-    public AppConfigPageController(AppConfigQuery appConfigQuery, ProjConfigQuery projConfigQuery, RepoAuthQuery repoAuthQuery,
+    public AppConfigPageController(AppConfigQuery appConfigQuery, ProjConfigQuery projConfigQuery, RepoAuthConfigQuery repoAuthConfigQuery,
                                    CompilerConfigQuery compilerConfigQuery, PackerConfigQuery packerConfigQuery, MachineHostQuery hostQuery,
                                    NotifyGroupRepository receiverRepository) {
         this.appConfigQuery = appConfigQuery;
         this.projConfigQuery = projConfigQuery;
-        this.repoAuthQuery = repoAuthQuery;
+        this.repoAuthConfigQuery = repoAuthConfigQuery;
         this.compilerConfigQuery = compilerConfigQuery;
         this.packerConfigQuery = packerConfigQuery;
         this.hostQuery = hostQuery;
@@ -147,7 +147,7 @@ public class AppConfigPageController {
         model.addAttribute("environments", envs);
         model.addAttribute("appTypes", appTypes);
 
-        List<KeyValue> repoAuths = repoAuthQuery.findAllByIsDeleteFalse().stream()
+        List<KeyValue> repoAuths = repoAuthConfigQuery.findAll().stream()
                 .map(repoAuthConfig -> new KeyValue(String.valueOf(repoAuthConfig.getName()), repoAuthConfig.getName()))
                 .collect(Collectors.toList());
 

+ 5 - 5
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/page/ProjConfigPageController.java

@@ -3,7 +3,7 @@ package cn.reghao.autodop.dmaster.app.controller.page;
 import cn.reghao.autodop.dmaster.app.db.query.config.ProjConfigQuery;
 import cn.reghao.autodop.dmaster.app.db.query.config.CompilerConfigQuery;
 import cn.reghao.autodop.dmaster.app.db.query.config.PackerConfigQuery;
-import cn.reghao.autodop.dmaster.app.db.query.config.RepoAuthQuery;
+import cn.reghao.autodop.dmaster.app.db.query.config.RepoAuthConfigQuery;
 import cn.reghao.autodop.dmaster.app.model.constant.AppType;
 import cn.reghao.autodop.dmaster.app.model.constant.EnvList;
 import cn.reghao.autodop.dmaster.app.model.po.config.ProjConfig;
@@ -35,14 +35,14 @@ import java.util.stream.Collectors;
 @RequestMapping("/app/config/proj")
 public class ProjConfigPageController {
     private final ProjConfigQuery projConfigQuery;
-    private final RepoAuthQuery repoAuthQuery;
+    private final RepoAuthConfigQuery repoAuthConfigQuery;
     private final CompilerConfigQuery compilerConfigQuery;
     private final PackerConfigQuery packerConfigQuery;
 
-    public ProjConfigPageController(ProjConfigQuery projConfigQuery, RepoAuthQuery repoAuthQuery,
+    public ProjConfigPageController(ProjConfigQuery projConfigQuery, RepoAuthConfigQuery repoAuthConfigQuery,
                                     CompilerConfigQuery compilerConfigQuery, PackerConfigQuery packerConfigQuery) {
         this.projConfigQuery = projConfigQuery;
-        this.repoAuthQuery = repoAuthQuery;
+        this.repoAuthConfigQuery = repoAuthConfigQuery;
         this.compilerConfigQuery = compilerConfigQuery;
         this.packerConfigQuery = packerConfigQuery;
     }
@@ -60,7 +60,7 @@ public class ProjConfigPageController {
         model.addAttribute("environments", envs);
         model.addAttribute("appTypes", appTypes);
 
-        List<KeyValue> repoAuths = repoAuthQuery.findAllByIsDeleteFalse().stream()
+        List<KeyValue> repoAuths = repoAuthConfigQuery.findAll().stream()
                 .map(repoAuthConfig -> new KeyValue(String.valueOf(repoAuthConfig.getName()), repoAuthConfig.getName()))
                 .collect(Collectors.toList());
 

+ 5 - 5
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/page/RepoAuthPageController.java

@@ -1,6 +1,6 @@
 package cn.reghao.autodop.dmaster.app.controller.page;
 
-import cn.reghao.autodop.dmaster.app.db.query.config.RepoAuthQuery;
+import cn.reghao.autodop.dmaster.app.db.query.config.RepoAuthConfigQuery;
 import cn.reghao.autodop.dmaster.app.model.constant.build.RepoAuthType;
 import cn.reghao.autodop.dmaster.app.model.constant.build.RepoType;
 import cn.reghao.autodop.dmaster.app.model.po.config.build.RepoAuthConfig;
@@ -30,17 +30,17 @@ import java.util.List;
 @Controller
 @RequestMapping("/app/config/build")
 public class RepoAuthPageController {
-    private RepoAuthQuery repoAuthQuery;
+    private RepoAuthConfigQuery repoAuthConfigQuery;
 
-    public RepoAuthPageController(RepoAuthQuery repoAuthQuery) {
-        this.repoAuthQuery = repoAuthQuery;
+    public RepoAuthPageController(RepoAuthConfigQuery repoAuthConfigQuery) {
+        this.repoAuthConfigQuery = repoAuthConfigQuery;
     }
 
     @ApiOperation(value = "仓库认证页面")
     @GetMapping("/repoauth")
     public String repoAuthPage(Model model) {
         PageRequest pageRequest = PageSort.pageRequest();
-        Page<RepoAuthConfig> page = repoAuthQuery.findAll(pageRequest);
+        Page<RepoAuthConfig> page = repoAuthConfigQuery.findByPage(pageRequest);
         PageList<RepoAuthConfig> pageList = PageList.pageList(page);
 
         model.addAttribute("page", page);

+ 5 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/crud/config/AppConfigCrud.java

@@ -49,6 +49,10 @@ public class AppConfigCrud {
         this.runningRepository = runningRepository;
     }
 
+    public void save(AppConfig appConfig) {
+        appRepository.save(appConfig);
+    }
+
     // TODO 数据修改后要在引用它的对象中立即体现
     //@CachePut(cacheNames = {"app"}, key = "#app.appId")
     @Transactional(rollbackFor = Exception.class)
@@ -154,7 +158,7 @@ public class AppConfigCrud {
 
     public Result copy(AppConfig from, NewApp to) throws Exception {
         if (from == null) {
-            String msg = "应用配置不存在...";
+            String msg = "应用配置不存在";
             return Result.result(ResultStatus.FAIL, msg);
         }
 

+ 2 - 70
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/crud/config/BuildDirCrud.java

@@ -1,79 +1,11 @@
 package cn.reghao.autodop.dmaster.app.db.crud.config;
 
-import cn.reghao.autodop.common.machine.disk.Disk;
-import cn.reghao.jdkutil.result.Result;
-import cn.reghao.jdkutil.result.ResultStatus;
-import cn.reghao.autodop.common.util.FileOps;
+import cn.reghao.jdkutil.db.BaseCrud;
 import cn.reghao.autodop.dmaster.app.model.po.config.build.BuildDir;
-import cn.reghao.autodop.dmaster.app.model.po.config.build.BuildDirLocal;
-import cn.reghao.autodop.dmaster.app.db.repository.config.build.BuildDirRepository;
-import org.springframework.stereotype.Service;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Objects;
 
 /**
  * @author reghao
  * @date 2020-11-10 21:58:00
  */
-@Service
-public class BuildDirCrud {
-    private BuildDirRepository buildDirRepository;
-    private Disk disk;
-
-    public BuildDirCrud(BuildDirRepository buildDirRepository, Disk disk) {
-        this.buildDirRepository = buildDirRepository;
-        this.disk = disk;
-    }
-
-    public void insert(BuildDir buildDir) {
-        buildDirRepository.save(buildDir);
-    }
-
-    /**
-     * TODO 整个操作应该线程安全,且处于一个事务中
-     *
-     * @param
-     * @return
-     * @date 2021-06-17 下午9:10
-     */
-    public synchronized Result update(BuildDir buildDir) {
-        if (buildDir.getId() == null) {
-            return Result.result(ResultStatus.FAIL, "构建目录不存在");
-        }
-
-        BuildDir oldBuildDir = buildDirRepository.findByMachineId(buildDir.getMachineId());
-        String oldDirPath = oldBuildDir.getDirPath();
-        String oldMountedOn = oldBuildDir.getMountedOn();
-        String newDirPath = buildDir.getDirPath();
-        String newMountedOn = disk.diskInfo(newDirPath).getMountedOn();
-
-        if (newDirPath.equals(oldDirPath)) {
-            return Result.result(ResultStatus.FAIL, "目录没有改变");
-        } else if (newMountedOn.equals(oldMountedOn)) {
-            return Result.result(ResultStatus.FAIL, "新目录和当前目录同属一个分区");
-        } else if (new File(newDirPath).exists()) {
-            return Result.result(ResultStatus.FAIL, "新目录已存在,请另外指定一个不存在的目录");
-        }
-
-        String oldPackDir = BuildDirLocal.packDir;
-        // TODO 目录迁移时不能有应用处于构建过程中
-        BuildDir newBuildDir = BuildDirLocal.setBuildDir(newDirPath);
-        File file = new File(oldPackDir);
-        if (Objects.requireNonNull(file.list()).length != 0) {
-            try {
-                FileOps.copyDirContentToDir(oldPackDir, BuildDirLocal.packDir);
-            } catch (IOException e) {
-                FileOps.delete(new File(newDirPath));
-                return Result.result(ResultStatus.ERROR, e.getMessage());
-            }
-        }
-        buildDirRepository.save(newBuildDir);
-        return Result.result(ResultStatus.SUCCESS);
-    }
-
-    public BuildDir selectByUniqueKey(String machineId) {
-        return buildDirRepository.findByMachineId(machineId);
-    }
+public interface BuildDirCrud extends BaseCrud<BuildDir> {
 }

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/crud/config/ProjConfigCrud.java

@@ -54,7 +54,7 @@ public class ProjConfigCrud {
 
     public Result copy(ProjConfig from, NewApp to) {
         if (from == null) {
-            String msg = "项目配置不存在...";
+            String msg = "项目配置不存在";
             return Result.result(ResultStatus.FAIL, msg);
         }
 

+ 2 - 77
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/crud/config/RepoAuthConfigCrud.java

@@ -1,86 +1,11 @@
 package cn.reghao.autodop.dmaster.app.db.crud.config;
 
-import cn.reghao.jdkutil.result.Result;
-import cn.reghao.jdkutil.result.ResultStatus;
-import cn.reghao.autodop.dmaster.app.model.constant.build.RepoAuthType;
-import cn.reghao.autodop.dmaster.app.model.constant.build.RepoType;
-import cn.reghao.autodop.dmaster.app.db.query.config.AppConfigQuery;
-import cn.reghao.autodop.dmaster.app.db.query.config.ProjConfigQuery;
-import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
-import cn.reghao.autodop.dmaster.app.model.po.config.ProjConfig;
+import cn.reghao.jdkutil.db.BaseCrud;
 import cn.reghao.autodop.dmaster.app.model.po.config.build.RepoAuthConfig;
-import cn.reghao.autodop.dmaster.app.db.repository.config.build.RepoAuthConfigRepository;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-import java.util.stream.Collectors;
 
 /**
  * @author reghao
  * @date 2020-11-10 21:58:00
  */
-@Service
-public class RepoAuthConfigCrud {
-    private RepoAuthConfigRepository repoAuthRepository;
-    private AppConfigQuery appConfigQuery;
-    private ProjConfigQuery projConfigQuery;
-
-    public RepoAuthConfigCrud(RepoAuthConfigRepository repoAuthRepository, AppConfigQuery appConfigQuery, ProjConfigQuery projConfigQuery) {
-        this.repoAuthRepository = repoAuthRepository;
-        this.appConfigQuery = appConfigQuery;
-        this.projConfigQuery = projConfigQuery;
-    }
-
-    public Result insertOrUpdate(RepoAuthConfig repoAuthConfig) {
-        Result result = valid(repoAuthConfig);
-        if (result.getCode() != ResultStatus.SUCCESS.getCode()) {
-            return result;
-        }
-        repoAuthRepository.save(repoAuthConfig);
-        return result;
-    }
-
-    private Result valid(RepoAuthConfig repoAuthConfig) {
-        switch (RepoType.valueOf(repoAuthConfig.getType())) {
-            case git:
-                switch (RepoAuthType.valueOf(repoAuthConfig.getAuthType())) {
-                    case ssh:
-                        String rsaPriKey = repoAuthConfig.getRsaPrikey();
-                        if (rsaPriKey.isEmpty() || rsaPriKey.isBlank()) {
-                            return Result.result(ResultStatus.FAIL, "RSA 私钥不能为空");
-                        }
-                        break;
-                    case http:
-                        String username = repoAuthConfig.getUsername();
-                        String password = repoAuthConfig.getPassword();
-                        if (username.isEmpty() || username.isBlank() || password.isEmpty() || password.isBlank()) {
-                            return Result.result(ResultStatus.FAIL, "用户名/密码不能为空");
-                        }
-                        break;
-                    default:
-                        return Result.result(ResultStatus.FAIL, "必须选择 git 的认证类型");
-                }
-                break;
-            case svn:
-                // TODO 暂未实现对 SVN 的验证
-                break;
-            default:
-                return Result.result(ResultStatus.FAIL, "暂不支持除 GIT/SVN 之外的版本管理工具");
-        }
-        return Result.result(ResultStatus.SUCCESS);
-    }
-
-    public Result delete(RepoAuthConfig repoAuthConfig) {
-        List<AppConfig> apps = appConfigQuery.findAllByRepoAuthConfig(repoAuthConfig);
-        List<ProjConfig> projs = projConfigQuery.findAllByRepoAuthConfig(repoAuthConfig);
-        if (apps.isEmpty() && projs.isEmpty()) {
-            repoAuthRepository.delete(repoAuthConfig);
-            return Result.result(ResultStatus.SUCCESS);
-        } else {
-            List<String> ids = apps.stream().map(AppConfig::getAppId).collect(Collectors.toList());
-            ids.addAll(projs.stream().map(ProjConfig::getProjId).collect(Collectors.toList()));
-            String msg = repoAuthConfig.getName() + " 删除失败, " + ids.toString() + " 等应用正在使用";
-            return Result.result(ResultStatus.FAIL, msg);
-        }
-    }
+public interface RepoAuthConfigCrud extends BaseCrud<RepoAuthConfig> {
 }

+ 9 - 9
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/crud/config/SharedEntityChecker.java

@@ -3,7 +3,7 @@ package cn.reghao.autodop.dmaster.app.db.crud.config;
 import cn.reghao.autodop.dmaster.app.db.query.config.ProjConfigQuery;
 import cn.reghao.autodop.dmaster.app.db.query.config.CompilerConfigQuery;
 import cn.reghao.autodop.dmaster.app.db.query.config.PackerConfigQuery;
-import cn.reghao.autodop.dmaster.app.db.query.config.RepoAuthQuery;
+import cn.reghao.autodop.dmaster.app.db.query.config.RepoAuthConfigQuery;
 import cn.reghao.autodop.dmaster.app.model.po.config.build.CompilerConfig;
 import cn.reghao.autodop.dmaster.app.model.po.config.build.PackerConfig;
 import cn.reghao.autodop.dmaster.app.model.po.config.build.RepoAuthConfig;
@@ -21,14 +21,14 @@ import org.springframework.stereotype.Service;
 @Service
 public class SharedEntityChecker {
     private ProjConfigQuery projConfigQuery;
-    private RepoAuthQuery repoAuthQuery;
+    private RepoAuthConfigQuery repoAuthConfigQuery;
     private CompilerConfigQuery compilerConfigQuery;
     private PackerConfigQuery packerConfigQuery;
 
-    public SharedEntityChecker(ProjConfigQuery projConfigQuery, RepoAuthQuery repoAuthQuery,
+    public SharedEntityChecker(ProjConfigQuery projConfigQuery, RepoAuthConfigQuery repoAuthConfigQuery,
                                CompilerConfigQuery compilerConfigQuery, PackerConfigQuery packerConfigQuery) {
         this.projConfigQuery = projConfigQuery;
-        this.repoAuthQuery = repoAuthQuery;
+        this.repoAuthConfigQuery = repoAuthConfigQuery;
         this.compilerConfigQuery = compilerConfigQuery;
         this.packerConfigQuery = packerConfigQuery;
     }
@@ -39,7 +39,7 @@ public class SharedEntityChecker {
         if (entity != null) {
             app.setProj(entity);
         } else {
-            throw new Exception("项目 " + proj.getProjId() + " 不存在...");
+            throw new Exception("项目 " + proj.getProjId() + " 不存在");
         }
     }
 
@@ -70,11 +70,11 @@ public class SharedEntityChecker {
 
     public void checkAndSetBuildConfig(BuildConfig buildConfig) throws Exception {
         RepoAuthConfig repoAuth = buildConfig.getRepoAuth();
-        RepoAuthConfig repoAuthConfig = repoAuthQuery.findByName(repoAuth.getName());
+        RepoAuthConfig repoAuthConfig = repoAuthConfigQuery.findByName(repoAuth.getName());
         if (repoAuthConfig != null) {
             buildConfig.setRepoAuth(repoAuthConfig);
         } else {
-            throw new Exception("仓库配置 " + repoAuth.getName() + " 不存在...");
+            throw new Exception("仓库配置 " + repoAuth.getName() + " 不存在");
         }
 
         CompilerConfig compiler = buildConfig.getCompiler();
@@ -82,7 +82,7 @@ public class SharedEntityChecker {
         if (compilerConfig != null) {
             buildConfig.setCompiler(compilerConfig);
         } else {
-            throw new Exception("编译器配置 " + compiler.getName() + " 不存在...");
+            throw new Exception("编译器配置 " + compiler.getName() + " 不存在");
         }
 
         PackerConfig packer = buildConfig.getPacker();
@@ -90,7 +90,7 @@ public class SharedEntityChecker {
         if (packerConfig != null) {
             buildConfig.setPacker(packerConfig);
         } else {
-            throw new Exception("打包配置 " + packer.getName() + " 不存在...");
+            throw new Exception("打包配置 " + packer.getName() + " 不存在");
         }
     }
 }

+ 40 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/crud/config/impl/BuildDirCrudImpl.java

@@ -0,0 +1,40 @@
+package cn.reghao.autodop.dmaster.app.db.crud.config.impl;
+
+import cn.reghao.autodop.dmaster.app.db.crud.config.BuildDirCrud;
+import cn.reghao.autodop.dmaster.app.db.repository.config.build.BuildDirRepository;
+import cn.reghao.autodop.dmaster.app.model.po.config.build.BuildDir;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author reghao
+ * @date 2020-11-10 21:58:00
+ */
+@Service
+public class BuildDirCrudImpl implements BuildDirCrud {
+    private BuildDirRepository buildDirRepository;
+
+    public BuildDirCrudImpl(BuildDirRepository buildDirRepository) {
+        this.buildDirRepository = buildDirRepository;
+    }
+
+    @Override
+    public BuildDir save(BuildDir buildDir) {
+        buildDirRepository.save(buildDir);
+        return buildDir;
+    }
+
+    @Override
+    public void saveAll(List<BuildDir> list) {
+    }
+
+    @Override
+    public void update(BuildDir buildDir) {
+        buildDirRepository.save(buildDir);
+    }
+
+    @Override
+    public void delete(BuildDir buildDir) {
+    }
+}

+ 105 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/crud/config/impl/RepoAuthConfigCrudImpl.java

@@ -0,0 +1,105 @@
+package cn.reghao.autodop.dmaster.app.db.crud.config.impl;
+
+import cn.reghao.autodop.dmaster.app.db.crud.config.RepoAuthConfigCrud;
+import cn.reghao.autodop.dmaster.app.db.query.config.AppConfigQuery;
+import cn.reghao.autodop.dmaster.app.db.query.config.ProjConfigQuery;
+import cn.reghao.autodop.dmaster.app.db.repository.config.build.RepoAuthConfigRepository;
+import cn.reghao.autodop.dmaster.app.model.constant.build.RepoAuthType;
+import cn.reghao.autodop.dmaster.app.model.constant.build.RepoType;
+import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
+import cn.reghao.autodop.dmaster.app.model.po.config.ProjConfig;
+import cn.reghao.autodop.dmaster.app.model.po.config.build.RepoAuthConfig;
+import cn.reghao.jdkutil.result.Result;
+import cn.reghao.jdkutil.result.ResultStatus;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author reghao
+ * @date 2020-11-10 21:58:00
+ */
+@Service
+public class RepoAuthConfigCrudImpl implements RepoAuthConfigCrud {
+    private RepoAuthConfigRepository repoAuthRepository;
+    private AppConfigQuery appConfigQuery;
+    private ProjConfigQuery projConfigQuery;
+
+    public RepoAuthConfigCrudImpl(RepoAuthConfigRepository repoAuthRepository, AppConfigQuery appConfigQuery,
+                                  ProjConfigQuery projConfigQuery) {
+        this.repoAuthRepository = repoAuthRepository;
+        this.appConfigQuery = appConfigQuery;
+        this.projConfigQuery = projConfigQuery;
+    }
+
+    @Override
+    public RepoAuthConfig save(RepoAuthConfig repoAuthConfig) {
+        repoAuthRepository.save(repoAuthConfig);
+        return repoAuthConfig;
+    }
+
+    @Override
+    public void saveAll(List<RepoAuthConfig> list) {
+    }
+
+    @Override
+    public void update(RepoAuthConfig repoAuthConfig) {
+        Result result = valid(repoAuthConfig);
+        repoAuthRepository.save(repoAuthConfig);
+    }
+
+    public Result insertOrUpdate(RepoAuthConfig repoAuthConfig) {
+        Result result = valid(repoAuthConfig);
+        if (result.getCode() != ResultStatus.SUCCESS.getCode()) {
+            return result;
+        }
+        repoAuthRepository.save(repoAuthConfig);
+        return result;
+    }
+
+    private Result valid(RepoAuthConfig repoAuthConfig) {
+        switch (RepoType.valueOf(repoAuthConfig.getType())) {
+            case git:
+                switch (RepoAuthType.valueOf(repoAuthConfig.getAuthType())) {
+                    case ssh:
+                        String rsaPriKey = repoAuthConfig.getRsaPrikey();
+                        if (rsaPriKey.isEmpty() || rsaPriKey.isBlank()) {
+                            return Result.result(ResultStatus.FAIL, "RSA 私钥不能为空");
+                        }
+                        break;
+                    case http:
+                        String username = repoAuthConfig.getUsername();
+                        String password = repoAuthConfig.getPassword();
+                        if (username.isEmpty() || username.isBlank() || password.isEmpty() || password.isBlank()) {
+                            return Result.result(ResultStatus.FAIL, "用户名/密码不能为空");
+                        }
+                        break;
+                    default:
+                        return Result.result(ResultStatus.FAIL, "必须选择 git 的认证类型");
+                }
+                break;
+            case svn:
+                // TODO 暂未实现对 SVN 的验证
+                break;
+            default:
+                return Result.result(ResultStatus.FAIL, "暂不支持除 GIT/SVN 之外的版本管理工具");
+        }
+        return Result.result(ResultStatus.SUCCESS);
+    }
+
+    @Override
+    public void delete(RepoAuthConfig repoAuthConfig) {
+        List<AppConfig> apps = appConfigQuery.findAllByRepoAuthConfig(repoAuthConfig);
+        List<ProjConfig> projs = projConfigQuery.findAllByRepoAuthConfig(repoAuthConfig);
+        if (apps.isEmpty() && projs.isEmpty()) {
+            repoAuthRepository.delete(repoAuthConfig);
+            //return Result.result(ResultStatus.SUCCESS);
+        } else {
+            List<String> ids = apps.stream().map(AppConfig::getAppId).collect(Collectors.toList());
+            ids.addAll(projs.stream().map(ProjConfig::getProjId).collect(Collectors.toList()));
+            String msg = repoAuthConfig.getName() + " 删除失败, " + ids.toString() + " 等应用正在使用";
+            //return Result.result(ResultStatus.FAIL, msg);
+        }
+    }
+}

+ 4 - 12
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/query/config/BuildDirQuery.java

@@ -2,6 +2,7 @@ package cn.reghao.autodop.dmaster.app.db.query.config;
 
 import cn.reghao.autodop.dmaster.app.model.po.config.build.BuildDir;
 import cn.reghao.autodop.dmaster.app.db.repository.config.build.BuildDirRepository;
+import cn.reghao.jdkutil.db.BaseQuery;
 import org.springframework.cache.annotation.CacheConfig;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
@@ -11,16 +12,7 @@ import org.springframework.stereotype.Service;
  * @author reghao
  * @date 2021-06-11 18:02:57
  */
-@CacheConfig(cacheNames = {"caffeineCacheManager"})
-@Service
-public class BuildDirQuery {
-    private BuildDirRepository buildDirRepository;
-
-    public BuildDirQuery(BuildDirRepository buildDirRepository) {
-        this.buildDirRepository = buildDirRepository;
-    }
-
-    public Page<BuildDir> findByPage(Pageable pageable) {
-        return buildDirRepository.findAll(pageable);
-    }
+public interface BuildDirQuery extends BaseQuery<BuildDir> {
+    Page<BuildDir> findByPage(Pageable pageable);
+    BuildDir findByMachineId(String machineId);
 }

+ 15 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/query/config/RepoAuthConfigQuery.java

@@ -0,0 +1,15 @@
+package cn.reghao.autodop.dmaster.app.db.query.config;
+
+import cn.reghao.autodop.dmaster.app.model.po.config.build.RepoAuthConfig;
+import cn.reghao.jdkutil.db.BaseQuery;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+
+/**
+ * @author reghao
+ * @date 2021-06-11 18:02:57
+ */
+public interface RepoAuthConfigQuery extends BaseQuery<RepoAuthConfig> {
+    RepoAuthConfig findByName(String name);
+    Page<RepoAuthConfig> findByPage(Pageable pageable);
+}

+ 31 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/query/config/impl/BuildDirQueryImpl.java

@@ -0,0 +1,31 @@
+package cn.reghao.autodop.dmaster.app.db.query.config.impl;
+
+import cn.reghao.autodop.dmaster.app.db.query.config.BuildDirQuery;
+import cn.reghao.autodop.dmaster.app.db.repository.config.build.BuildDirRepository;
+import cn.reghao.autodop.dmaster.app.model.po.config.build.BuildDir;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author reghao
+ * @date 2021-06-11 18:02:57
+ */
+@Service
+public class BuildDirQueryImpl implements BuildDirQuery {
+    private BuildDirRepository buildDirRepository;
+
+    public BuildDirQueryImpl(BuildDirRepository buildDirRepository) {
+        this.buildDirRepository = buildDirRepository;
+    }
+
+    @Override
+    public Page<BuildDir> findByPage(Pageable pageable) {
+        return buildDirRepository.findAll(pageable);
+    }
+
+    @Override
+    public BuildDir findByMachineId(String machineId) {
+        return buildDirRepository.findByMachineId(machineId);
+    }
+}

+ 10 - 8
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/query/config/RepoAuthQuery.java → dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/query/config/impl/RepoAuthConfigQueryImpl.java

@@ -1,7 +1,8 @@
-package cn.reghao.autodop.dmaster.app.db.query.config;
+package cn.reghao.autodop.dmaster.app.db.query.config.impl;
 
-import cn.reghao.autodop.dmaster.app.model.po.config.build.RepoAuthConfig;
+import cn.reghao.autodop.dmaster.app.db.query.config.RepoAuthConfigQuery;
 import cn.reghao.autodop.dmaster.app.db.repository.config.build.RepoAuthConfigRepository;
+import cn.reghao.autodop.dmaster.app.model.po.config.build.RepoAuthConfig;
 import org.springframework.cache.annotation.CacheConfig;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
@@ -13,25 +14,26 @@ import java.util.List;
  * @author reghao
  * @date 2021-06-11 18:02:57
  */
-@CacheConfig(cacheNames = {"caffeineCacheManager"})
 @Service
-public class RepoAuthQuery {
+public class RepoAuthConfigQueryImpl implements RepoAuthConfigQuery {
     private RepoAuthConfigRepository repoAuthRepository;
 
-    public RepoAuthQuery(RepoAuthConfigRepository repoAuthRepository) {
+    public RepoAuthConfigQueryImpl(RepoAuthConfigRepository repoAuthRepository) {
         this.repoAuthRepository = repoAuthRepository;
     }
 
-    //@Cacheable(cacheNames = {"repoAuth"}, key = "#name")
+    @Override
     public RepoAuthConfig findByName(String name) {
         return repoAuthRepository.findByName(name);
     }
 
-    public Page<RepoAuthConfig> findAll(Pageable pageable) {
+    @Override
+    public Page<RepoAuthConfig> findByPage(Pageable pageable) {
         return repoAuthRepository.findAll(pageable);
     }
 
-    public List<RepoAuthConfig> findAllByIsDeleteFalse() {
+    @Override
+    public List<RepoAuthConfig> findAll() {
         return repoAuthRepository.findAllByIsDeleteFalse();
     }
 }

+ 4 - 4
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/po/config/build/BuildDirLocal.java

@@ -53,17 +53,17 @@ public class BuildDirLocal {
         setLocalBuildDir(buildDir);
         File localRepo = new File(BuildDirLocal.localRepo);
         if (!localRepo.exists() && !FileOps.mkdirs(localRepo)) {
-            throw new IllegalArgumentException(localRepo.getAbsolutePath() + " 不存在且创建失败...");
+            throw new IllegalArgumentException(localRepo.getAbsolutePath() + " 不存在且创建失败");
         }
 
         File compileDir = new File(BuildDirLocal.compileDir);
         if (!compileDir.exists() && !FileOps.mkdirs(compileDir)) {
-            throw new IllegalArgumentException(compileDir.getAbsolutePath() + " 不存在且创建失败...");
+            throw new IllegalArgumentException(compileDir.getAbsolutePath() + " 不存在且创建失败");
         }
 
         File packDir = new File(BuildDirLocal.packDir);
         if (!packDir.exists() && !FileOps.mkdirs(packDir)) {
-            throw new IllegalArgumentException(packDir.getAbsolutePath() + " 不存在且创建失败...");
+            throw new IllegalArgumentException(packDir.getAbsolutePath() + " 不存在且创建失败");
         }
     }
 
@@ -81,7 +81,7 @@ public class BuildDirLocal {
             buildDir.setUsed(converter.convertStr(ByteType.Bytes, ByteType.MiB, diskInfo.getUsed()));
             buildDir.setAvail(converter.convertStr(ByteType.Bytes, ByteType.MiB, diskInfo.getAvail()));
         } else {
-            log.error("{} 不合法,autodop-master 启动失败...", dirPath);
+            log.error("{} 不合法,autodop-master 启动失败", dirPath);
             System.exit(1);
         }
     }

+ 6 - 4
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/AppStatusService.java

@@ -63,11 +63,12 @@ public class AppStatusService {
         asyncMsg.setPayload(JsonConverter.objectToJson(appIdParam));
 
         String topic = "dagent/" + machineId;
-        try {
+        // TODO 获取应用状态
+        /*try {
             mqttClient.pubWithResult(topic, 1, asyncMsg);
         } catch (MqttException e) {
             e.printStackTrace();
-        }
+        }*/
     }
 
     public void refreshAppStatus() {
@@ -101,11 +102,12 @@ public class AppStatusService {
         asyncMsg.setPayload(JsonConverter.objectToJson(appIdParam));
 
         String topic = "dagent/" + machineId;
-        try {
+        // TODO 获取应用状态
+        /*try {
             mqttClient.pubWithResult(topic, 1, asyncMsg);
         } catch (MqttException e) {
             e.printStackTrace();
-        }
+        }*/
     }
 
     /**

+ 5 - 5
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/BuildDeployDispatcher.java

@@ -91,13 +91,13 @@ public class BuildDeployDispatcher {
         AppConfig app = appConfigQuery.findByAppId(appId);
         if (app == null) {
             onBuilding.remove(appId);
-            throw new Exception(appId + " 不存在...");
+            throw new Exception(appId + " 不存在");
         }
         AppIntegrate appIntegrate = new AppIntegrate(app);
 
         BuildSupplier supplier = new BuildSupplier(appIntegrate);
         List<NotifyGroup> notifyGroups = app.getNotifyGroups();
-        log.info("开始异步构建 {}...", appId);
+        log.info("开始异步构建 {}", appId);
         CompletableFuture.supplyAsync(supplier, threadPool)
                 .whenComplete((buildLog, throwable) -> {
                     onBuilding.remove(appId);
@@ -120,7 +120,7 @@ public class BuildDeployDispatcher {
                         }
                         appDeployingRepository.saveAll(appDeployings);
                     }
-                    log.info("{} 构建完成...", appId);
+                    log.info("{} 构建完成", appId);
                 })
                 .thenAccept(buildLog -> {
                     if (!isDeploy) {
@@ -129,7 +129,7 @@ public class BuildDeployDispatcher {
                     }
 
                     if (buildLog.getResult().getCode() == ResultStatus.SUCCESS.getCode() && isDeploy) {
-                        log.info("开始部署 {}...", appId);
+                        log.info("开始部署 {}", appId);
                         try {
                             appDeployer.deploy(buildLog);
                         } catch (MqttException e) {
@@ -152,7 +152,7 @@ public class BuildDeployDispatcher {
             case sms:
                 break;
             default:
-                log.error("通知类型不存在...");
+                log.error("通知类型不存在");
         }
     }
 

+ 1 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/BuildDeployService.java

@@ -5,6 +5,7 @@ package cn.reghao.autodop.dmaster.app.service;
  * @date 2021-09-17 11:30:16
  */
 public interface BuildDeployService {
+    String buildAndDeploy(String appId);
     String build(String appId);
     String build(String appId, String commitId);
     boolean deploy(String appId, String commitId);

+ 13 - 2
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppDeployer.java

@@ -3,8 +3,14 @@ package cn.reghao.autodop.dmaster.app.service.bd;
 import cn.reghao.autodop.common.message.AsyncMsg;
 import cn.reghao.autodop.common.message.MessageType;
 import cn.reghao.autodop.common.message.ops.AppOps;
+import cn.reghao.autodop.common.msg.Message;
+import cn.reghao.autodop.common.msg.MsgQueue;
+import cn.reghao.autodop.common.msg.rpc.RpcMsg;
+import cn.reghao.autodop.common.msg.rpc.RpcPayload;
+import cn.reghao.autodop.common.msg.rpc.clazz.AppRpcClazz;
 import cn.reghao.autodop.common.msg.rpc.dto.app.DeployParam;
 import cn.reghao.autodop.common.mqtt.DefaultMqttClient;
+import cn.reghao.jdkutil.MachineId;
 import cn.reghao.jdkutil.serializer.JsonConverter;
 import cn.reghao.autodop.dmaster.app.db.query.config.AppConfigQuery;
 import cn.reghao.autodop.dmaster.app.model.po.config.DeployConfig;
@@ -53,9 +59,14 @@ public class AppDeployer {
             asyncMsg.setOps(AppOps.appDeploy.name());
             asyncMsg.setPayload(JsonConverter.objectToJson(deployParam));
 
+            RpcPayload rpcPayload = RpcPayload.rpcPayload(
+                    AppRpcClazz.class.getSimpleName(), AppRpcClazz.deploy.name(), deployParam);
+            RpcMsg rpcMsg = RpcMsg.callMsg(rpcPayload);
+            Message message = Message.rpcMessage("", "", rpcMsg);
+
             // TODO 对于需要返回值的 pub,需要做一个记录,pub 和 sub 一一对应
-            String topic = "dagent/" + machineId;
-            mqttClient.pubWithResult(topic, 1, asyncMsg);
+            String topic = MsgQueue.dagentTopic(MachineId.id());
+            mqttClient.pubWithResult(topic, 1, message);
         }
     }
 

+ 2 - 2
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppIntegrate.java

@@ -115,7 +115,7 @@ public class AppIntegrate {
                 codeCompiler = new NullCompiler();
                 break;
             default:
-                log.info("暂未实现,使用 NullCompiler...");
+                log.info("暂未实现,使用 NullCompiler");
                 codeCompiler = new NullCompiler();
         }
 
@@ -177,7 +177,7 @@ public class AppIntegrate {
             if (latestCommitInfo.getCommitId().equals(current.getCommitId())) {
                 return new UpdateStatus(current, false);
             } else if (latestCommitInfo.getMsCommitTime() > current.getMsCommitTime()) {
-                throw new Exception("本地仓库代码比远程仓库更新...");
+                throw new Exception("本地仓库代码比远程仓库更新");
             }
         }
 

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/tools/compiler/MavenCompiler.java

@@ -41,7 +41,7 @@ public class MavenCompiler implements CodeCompiler {
         if (result.getExitCode() != 0) {
             throw new Exception(compileLog.toString());
         } else {
-            log.info("构建成功...");
+            log.info("构建成功");
         }
     }
 

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/tools/packer/ZipPack.java

@@ -22,7 +22,7 @@ public class ZipPack implements CodePacker {
 
     @Override
     public String pack(String appId, String commitId, String appCompileHome) throws Exception {
-        log.info("生成 zip 包...");
+        log.info("生成 zip 包");
         /*String tag = appId + "_" + commitId + SUFFIX;
         String dst = targetPath + "/" + tag;
         if (new File(dst).exists()) {

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/tools/repo/GitImpl.java

@@ -96,7 +96,7 @@ public class GitImpl implements CodeUpdater {
         String localRepoDir = local + dirname(remote);
         File file = new File(localRepoDir);
         if (!file.exists() && !file.mkdirs()) {
-            throw new Exception("创建 " + localRepoDir + " 目录失败...");
+            throw new Exception("创建 " + localRepoDir + " 目录失败");
         }
 
         File localRepo = new File(localRepoDir + "/.git");

+ 9 - 3
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/AppConfigService.java

@@ -2,6 +2,9 @@ package cn.reghao.autodop.dmaster.app.service.config;
 
 import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
 import cn.reghao.autodop.dmaster.app.model.po.config.DeployConfig;
+import cn.reghao.autodop.dmaster.app.model.vo.NewApp;
+import cn.reghao.autodop.dmaster.notification.model.po.NotifyGroup;
+import cn.reghao.jdkutil.result.Result;
 
 import java.util.List;
 
@@ -10,7 +13,10 @@ import java.util.List;
  * @date 2021-09-16 18:28:51
  */
 public interface AppConfigService {
-    void add(AppConfig appConfig);
-    void update(AppConfig appConfig);
-    void setDeployConfig(int id, List<DeployConfig> deployConfigs);
+    Result add(AppConfig appConfig);
+    Result setDeployConfig(int id, List<DeployConfig> deployConfigs);
+    Result setNotify(int id, List<NotifyGroup> notifyGroups);
+    Result copy(AppConfig from, NewApp to);
+    Result update(AppConfig appConfig);
+    Result delete(AppConfig appConfig);
 }

+ 0 - 23
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/AppConfigServiceImpl.java

@@ -1,23 +0,0 @@
-package cn.reghao.autodop.dmaster.app.service.config;
-
-import cn.reghao.autodop.dmaster.app.db.crud.config.AppConfigCrud;
-import cn.reghao.autodop.dmaster.app.model.po.config.DeployConfig;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-/**
- * @author reghao
- * @date 2021-09-16 18:28:51
- */
-@Service
-public class AppConfigServiceImpl {
-    private AppConfigCrud appConfigCrud;
-
-    public AppConfigServiceImpl(AppConfigCrud appConfigCrud) {
-        this.appConfigCrud = appConfigCrud;
-    }
-
-    public void setDeployConfig(int id, List<DeployConfig> deployConfigs) {
-    }
-}

+ 6 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/BuildDirService.java

@@ -1,8 +1,14 @@
 package cn.reghao.autodop.dmaster.app.service.config;
 
+import cn.reghao.autodop.dmaster.app.model.po.config.build.BuildDir;
+import cn.reghao.jdkutil.result.Result;
+
 /**
  * @author reghao
  * @date 2021-09-17 15:56:49
  */
 public interface BuildDirService {
+    void add(BuildDir buildDir);
+    Result modify(BuildDir buildDir);
+    BuildDir get(String machineId);
 }

+ 6 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/CompilerConfigService.java

@@ -1,8 +1,14 @@
 package cn.reghao.autodop.dmaster.app.service.config;
 
+import cn.reghao.autodop.dmaster.app.model.po.config.build.CompilerConfig;
+import cn.reghao.jdkutil.result.Result;
+
 /**
  * @author reghao
  * @date 2021-09-17 15:54:07
  */
 public interface CompilerConfigService {
+    Result add(CompilerConfig compilerConfig);
+    Result modify(CompilerConfig compilerConfig);
+    Result delete(CompilerConfig compilerConfig);
 }

+ 6 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/PackerConfigService.java

@@ -1,8 +1,14 @@
 package cn.reghao.autodop.dmaster.app.service.config;
 
+import cn.reghao.autodop.dmaster.app.model.po.config.build.PackerConfig;
+import cn.reghao.jdkutil.result.Result;
+
 /**
  * @author reghao
  * @date 2021-09-17 15:54:16
  */
 public interface PackerConfigService {
+    Result add(PackerConfig packerConfig);
+    Result modify(PackerConfig packerConfig);
+    Result delete(PackerConfig packerConfig);
 }

+ 8 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/ProjConfigService.java

@@ -1,8 +1,16 @@
 package cn.reghao.autodop.dmaster.app.service.config;
 
+import cn.reghao.autodop.dmaster.app.model.po.config.ProjConfig;
+import cn.reghao.autodop.dmaster.app.model.vo.NewApp;
+import cn.reghao.jdkutil.result.Result;
+
 /**
  * @author reghao
  * @date 2021-09-17 10:13:46
  */
 public interface ProjConfigService {
+    Result add(ProjConfig projConfig);
+    Result copy(ProjConfig from, NewApp to);
+    Result modify(ProjConfig projConfig);
+    Result delete(ProjConfig projConfig);
 }

+ 7 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/RepoAuthConfigService.java

@@ -1,8 +1,15 @@
 package cn.reghao.autodop.dmaster.app.service.config;
 
+import cn.reghao.autodop.dmaster.app.model.po.config.build.RepoAuthConfig;
+import cn.reghao.jdkutil.result.Result;
+
 /**
  * @author reghao
  * @date 2021-09-17 10:16:07
  */
 public interface RepoAuthConfigService {
+    Result add(RepoAuthConfig repoAuthConfig);
+    Result modify(RepoAuthConfig repoAuthConfig);
+    Result delete(RepoAuthConfig repoAuthConfig);
+    RepoAuthConfig get(String name);
 }

+ 238 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/AppConfigServiceImpl.java

@@ -0,0 +1,238 @@
+package cn.reghao.autodop.dmaster.app.service.config.impl;
+
+import cn.reghao.autodop.dmaster.app.db.crud.config.SharedEntityChecker;
+import cn.reghao.autodop.dmaster.app.db.repository.AppRunningRepository;
+import cn.reghao.autodop.dmaster.app.db.repository.config.AppConfigRepository;
+import cn.reghao.autodop.dmaster.app.model.constant.AppType;
+import cn.reghao.autodop.dmaster.app.model.constant.EnvList;
+import cn.reghao.autodop.dmaster.app.model.po.AppRunning;
+import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
+import cn.reghao.autodop.dmaster.app.model.po.config.DeployConfig;
+import cn.reghao.autodop.dmaster.app.model.po.config.ProjConfig;
+import cn.reghao.autodop.dmaster.app.model.vo.NewApp;
+import cn.reghao.autodop.dmaster.app.service.AppBuildDeployService;
+import cn.reghao.autodop.dmaster.app.service.config.AppConfigService;
+import cn.reghao.autodop.dmaster.machine.db.query.MachineHostQuery;
+import cn.reghao.autodop.dmaster.machine.model.po.MachineHost;
+import cn.reghao.autodop.dmaster.notification.model.po.NotifyGroup;
+import cn.reghao.autodop.dmaster.notification.model.po.NotifyType;
+import cn.reghao.jdkutil.result.Result;
+import cn.reghao.jdkutil.result.ResultStatus;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * @author reghao
+ * @date 2021-09-16 18:28:51
+ */
+@Service
+public class AppConfigServiceImpl implements AppConfigService {
+    private AppConfigRepository appRepository;
+    private MachineHostQuery machineHostQuery;
+    private SharedEntityChecker sharedEntityChecker;
+    private AppBuildDeployService appBuildService;
+    private AppRunningRepository runningRepository;
+
+    public AppConfigServiceImpl(AppConfigRepository appRepository,
+                         MachineHostQuery machineHostQuery,
+                         SharedEntityChecker sharedEntityChecker,
+                         AppBuildDeployService appBuildService,
+                         AppRunningRepository runningRepository) {
+        this.appRepository = appRepository;
+        this.machineHostQuery = machineHostQuery;
+        this.sharedEntityChecker = sharedEntityChecker;
+        this.appBuildService = appBuildService;
+        this.runningRepository = runningRepository;
+    }
+
+    @Override
+    public Result setDeployConfig(int id, List<DeployConfig> deployConfigs) {
+        return Result.success("");
+    }
+
+    public void save(AppConfig appConfig) {
+        appRepository.save(appConfig);
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public Result add(AppConfig app) {
+        // TODO 处理所有与 app 关联的数据
+        // TODO 不能有应用处于构建中
+        Integer id = app.getId();
+        /*if (id != null) {
+            app = appRepository.findById(id).orElse(null);
+        }*/
+
+        Result result = checkEnum(app);
+        if (result.getCode() != ResultStatus.SUCCESS.getCode()) {
+            return result;
+        }
+
+        // 首先处理共享实体,将 app 的所有属性填充完整
+        try {
+            checkSharedEntity(app);
+        } catch (Exception e) {
+            return Result.fail(e.getMessage());
+        }
+
+        checkNotifyGroups(app);
+        checkDeployConfigs(app);
+        appRepository.save(app);
+        appBuildService.refreshApp(app);
+
+        String msg = id != null ? "更新 " + app.getAppId() + " 成功"
+                : "添加 " + app.getAppId() + " 成功";
+        return Result.result(ResultStatus.SUCCESS, msg);
+    }
+
+    @Override
+    public Result update(AppConfig app) {
+        // TODO 处理所有与 app 关联的数据
+        // TODO 不能有应用处于构建中
+        Integer id = app.getId();
+        /*if (id != null) {
+            app = appRepository.findById(id).orElse(null);
+        }*/
+
+        Result result = checkEnum(app);
+        if (result.getCode() != ResultStatus.SUCCESS.getCode()) {
+            return result;
+        }
+
+        // 首先处理共享实体,将 app 的所有属性填充完整
+        try {
+            checkSharedEntity(app);
+        } catch (Exception e) {
+            return Result.fail(e.getMessage());
+        }
+
+        checkNotifyGroups(app);
+        checkDeployConfigs(app);
+        appRepository.save(app);
+        appBuildService.refreshApp(app);
+
+        String msg = id != null ? "更新 " + app.getAppId() + " 成功"
+                : "添加 " + app.getAppId() + " 成功";
+        return Result.result(ResultStatus.SUCCESS, msg);
+    }
+
+    @Override
+    public Result setNotify(int id, List<NotifyGroup> notifyGroups) {
+        //appRepository.save(app);
+        return Result.result(ResultStatus.SUCCESS);
+    }
+
+    private Result checkEnum(AppConfig app) {
+        Set<String> envs = Arrays.stream(EnvList.values())
+                .map(Enum::name)
+                .collect(Collectors.toSet());
+        String env = app.getEnv();
+        if (!envs.contains(env)) {
+            String msg = env + " 环境不存在";
+            return Result.result(ResultStatus.FAIL, msg);
+        }
+
+        String appType = app.getAppType();
+        Set<String> appTypes = Arrays.stream(AppType.values())
+                .map(Enum::name)
+                .collect(Collectors.toSet());
+        if (!appTypes.contains(appType)) {
+            String msg = appType + " 类型不存在";
+            return Result.result(ResultStatus.FAIL, msg);
+        }
+
+        return Result.result(ResultStatus.SUCCESS);
+    }
+
+    private void checkNotifyGroups(AppConfig app) {
+        // TODO 根据通知类型创建相应的通知实例
+
+        Set<String> notifyTypes = Arrays.stream(NotifyType.values())
+                .map(Enum::name)
+                .collect(Collectors.toSet());
+        // TODO notifyReceivers 为 null 时会发生异常,好像不能正常返回,后面需要测试一下
+        /*List<NotifyReceiver> notifyReceivers = app.getNotifyReceivers().stream()
+                .filter(notifyReceiver -> notifyTypes.contains(notifyReceiver.getNotifyType()))
+                .collect(Collectors.toList());
+        app.setNotifyReceivers(notifyReceivers);*/
+    }
+
+    private void checkDeployConfigs(AppConfig app) {
+        // TODO null 异常不会被 ControllerExceptionHandler 捕获
+        ProjConfig proj = app.getProj();
+        String packType;
+        if (proj != null) {
+            packType = proj.getPackerConfig().getType();
+        } else {
+            packType = app.getPackerConfig().getType();
+        }
+
+        List<DeployConfig> deployConfigs = app.getDeployConfigs().stream()
+                .map(deployConfig -> {
+                    String machineId = deployConfig.getMachineId();
+                    MachineHost machineHost = machineHostQuery.findByMachineId(machineId);
+                    if (machineHost != null) {
+                        deployConfig.setMachineIpv4(machineHost.getMachineIpv4());
+                        deployConfig.setPackType(packType);
+                        return deployConfig;
+                    } else {
+                        return null;
+                    }
+                })
+                .filter(Objects::nonNull)
+                .collect(Collectors.toList());
+        app.setDeployConfigs(deployConfigs);
+    }
+
+    private void checkSharedEntity(AppConfig app) throws Exception {
+        if (app.getProj() == null) {
+            sharedEntityChecker.checkAndSetBuildConfig(app);
+        } else {
+            sharedEntityChecker.checkAndSetProj(app);
+        }
+    }
+
+    @Override
+    public Result copy(AppConfig from, NewApp to) {
+        if (from == null) {
+            String msg = "应用配置不存在";
+            return Result.result(ResultStatus.FAIL, msg);
+        }
+
+        AppConfig toApp = appRepository.findByIsDeleteFalseAndAppId(to.getNewId());
+        if (toApp != null) {
+            String msg = to.getNewId() + " 已存在";
+            return Result.result(ResultStatus.FAIL, msg);
+        }
+
+        try {
+            toApp = to.app((AppConfig) from.clone());
+            return add(toApp);
+        } catch (CloneNotSupportedException e) {
+            return Result.fail(e.getMessage());
+        }
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public Result delete(AppConfig app) {
+        String appId = app.getAppId();
+        List<AppRunning> appRunnings = runningRepository.findByAppId(appId).stream()
+                .filter(AppRunning::getIsRunning).collect(Collectors.toList());
+        if (!appRunnings.isEmpty()) {
+            return Result.result(ResultStatus.FAIL, appId + " 正在运行中");
+        }
+
+        // TODO 处理所有与 app 关联的数据
+        appBuildService.delete(app.getAppId());
+        appRepository.delete(app);
+        return Result.result(ResultStatus.SUCCESS);
+    }
+}

+ 80 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/BuildDirServiceImpl.java

@@ -0,0 +1,80 @@
+package cn.reghao.autodop.dmaster.app.service.config.impl;
+
+import cn.reghao.autodop.common.machine.disk.Disk;
+import cn.reghao.autodop.common.util.FileOps;
+import cn.reghao.autodop.dmaster.app.db.crud.config.BuildDirCrud;
+import cn.reghao.autodop.dmaster.app.db.query.config.BuildDirQuery;
+import cn.reghao.autodop.dmaster.app.model.po.config.build.BuildDir;
+import cn.reghao.autodop.dmaster.app.model.po.config.build.BuildDirLocal;
+import cn.reghao.autodop.dmaster.app.service.config.BuildDirService;
+import cn.reghao.jdkutil.result.Result;
+import cn.reghao.jdkutil.result.ResultStatus;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Objects;
+
+/**
+ * @author reghao
+ * @date 2021-09-17 15:56:49
+ */
+@Service
+public class BuildDirServiceImpl implements BuildDirService {
+    private BuildDirQuery buildDirQuery;
+    private BuildDirCrud buildDirCrud;
+    private Disk disk;
+
+    public BuildDirServiceImpl(BuildDirQuery buildDirQuery, BuildDirCrud buildDirCrud, Disk disk) {
+        this.buildDirQuery = buildDirQuery;
+        this.buildDirCrud = buildDirCrud;
+        this.disk = disk;
+    }
+
+    @Override
+    public void add(BuildDir buildDir) {
+        buildDirCrud.save(buildDir);
+    }
+
+    @Override
+    public Result modify(BuildDir buildDir) {
+        if (buildDir.getId() == null) {
+            return Result.result(ResultStatus.FAIL, "构建目录不存在");
+        }
+
+        BuildDir oldBuildDir = buildDirQuery.findByMachineId(buildDir.getMachineId());
+        String oldDirPath = oldBuildDir.getDirPath();
+        String oldMountedOn = oldBuildDir.getMountedOn();
+        String newDirPath = buildDir.getDirPath();
+        String newMountedOn = disk.diskInfo(newDirPath).getMountedOn();
+
+        if (newDirPath.equals(oldDirPath)) {
+            return Result.result(ResultStatus.FAIL, "目录没有改变");
+        } else if (newMountedOn.equals(oldMountedOn)) {
+            return Result.result(ResultStatus.FAIL, "新目录和当前目录同属一个分区");
+        } else if (new File(newDirPath).exists()) {
+            return Result.result(ResultStatus.FAIL, "新目录已存在,请另外指定一个不存在的目录");
+        }
+
+        String oldPackDir = BuildDirLocal.packDir;
+        // TODO 目录迁移时不能有应用处于构建过程中
+        BuildDir newBuildDir = BuildDirLocal.setBuildDir(newDirPath);
+        File file = new File(oldPackDir);
+        if (Objects.requireNonNull(file.list()).length != 0) {
+            try {
+                FileOps.copyDirContentToDir(oldPackDir, BuildDirLocal.packDir);
+            } catch (IOException e) {
+                FileOps.delete(new File(newDirPath));
+                return Result.result(ResultStatus.ERROR, e.getMessage());
+            }
+        }
+
+        buildDirCrud.save(newBuildDir);
+        return Result.result(ResultStatus.SUCCESS);
+    }
+
+    @Override
+    public BuildDir get(String machineId) {
+        return buildDirQuery.findByMachineId(machineId);
+    }
+}

+ 97 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/CompilerConfigServiceImpl.java

@@ -0,0 +1,97 @@
+package cn.reghao.autodop.dmaster.app.service.config.impl;
+
+import cn.reghao.autodop.dmaster.app.db.query.config.AppConfigQuery;
+import cn.reghao.autodop.dmaster.app.db.query.config.ProjConfigQuery;
+import cn.reghao.autodop.dmaster.app.db.repository.config.build.CompilerConfigRepository;
+import cn.reghao.autodop.dmaster.app.model.constant.build.CompileType;
+import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
+import cn.reghao.autodop.dmaster.app.model.po.config.ProjConfig;
+import cn.reghao.autodop.dmaster.app.model.po.config.build.CompilerConfig;
+import cn.reghao.autodop.dmaster.app.service.config.CompilerConfigService;
+import cn.reghao.jdkutil.result.Result;
+import cn.reghao.jdkutil.result.ResultStatus;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author reghao
+ * @date 2021-09-17 15:54:07
+ */
+@Service
+public class CompilerConfigServiceImpl implements CompilerConfigService {
+    private CompilerConfigRepository compilerRepository;
+    private AppConfigQuery appConfigQuery;
+    private ProjConfigQuery projConfigQuery;
+
+    public CompilerConfigServiceImpl(CompilerConfigRepository compilerRepository, AppConfigQuery appConfigQuery, ProjConfigQuery projConfigQuery) {
+        this.compilerRepository = compilerRepository;
+        this.appConfigQuery = appConfigQuery;
+        this.projConfigQuery = projConfigQuery;
+    }
+
+    @Override
+    public Result add(CompilerConfig compilerConfig) {
+        Result result = valid(compilerConfig);
+        if (result.getCode() != ResultStatus.SUCCESS.getCode()) {
+            return result;
+        }
+        compilerRepository.save(compilerConfig);
+        return result;
+    }
+
+    @Override
+    public Result modify(CompilerConfig compilerConfig) {
+        Result result = valid(compilerConfig);
+        if (result.getCode() != ResultStatus.SUCCESS.getCode()) {
+            return result;
+        }
+        compilerRepository.save(compilerConfig);
+        return result;
+    }
+
+    private Result valid(CompilerConfig compilerConfig) {
+        String type = compilerConfig.getType();
+        switch (CompileType.valueOf(type)) {
+            case shell:
+                if (compilerConfig.getCompileCmd().isEmpty() || compilerConfig.getCompileCmd().isBlank()) {
+                    // TODO 检测编译命令是否有效
+                    return Result.result(ResultStatus.FAIL, "必须指定编译命令");
+                }
+                break;
+            case maven:
+                String homePath = compilerConfig.getHomePath();
+                if (homePath.isEmpty() || homePath.isBlank()) {
+                    return Result.result(ResultStatus.FAIL, "必须指定 maven 的主目录");
+                }
+                break;
+            case docker:
+                if (compilerConfig.getCompileCmd().isEmpty() || compilerConfig.getCompileCmd().isBlank()) {
+                    // TODO 检测 dockerfile 是否有效
+                    return Result.result(ResultStatus.FAIL, "编译命令应该是 dockerfile");
+                }
+                break;
+            case no_need_compile:
+                break;
+            default:
+                return Result.result(ResultStatus.FAIL, "暂不支持 " + type);
+        }
+        return Result.result(ResultStatus.SUCCESS);
+    }
+
+    @Override
+    public Result delete(CompilerConfig compilerConfig) {
+        List<AppConfig> apps = appConfigQuery.findAllByCompilerConfig(compilerConfig);
+        List<ProjConfig> projs = projConfigQuery.findAllByCompilerConfig(compilerConfig);
+        if (apps.isEmpty() && projs.isEmpty()) {
+            compilerRepository.delete(compilerConfig);
+            return Result.result(ResultStatus.SUCCESS);
+        } else {
+            List<String> ids = apps.stream().map(AppConfig::getAppId).collect(Collectors.toList());
+            ids.addAll(projs.stream().map(ProjConfig::getProjId).collect(Collectors.toList()));
+            String msg = compilerConfig.getName() + " 删除失败, " + ids.toString() + " 等应用正在使用";
+            return Result.result(ResultStatus.FAIL, msg);
+        }
+    }
+}

+ 59 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/PackerConfigServiceImpl.java

@@ -0,0 +1,59 @@
+package cn.reghao.autodop.dmaster.app.service.config.impl;
+
+import cn.reghao.autodop.dmaster.app.db.query.config.AppConfigQuery;
+import cn.reghao.autodop.dmaster.app.db.query.config.ProjConfigQuery;
+import cn.reghao.autodop.dmaster.app.db.repository.config.build.PackerConfigRepository;
+import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
+import cn.reghao.autodop.dmaster.app.model.po.config.ProjConfig;
+import cn.reghao.autodop.dmaster.app.model.po.config.build.PackerConfig;
+import cn.reghao.autodop.dmaster.app.service.config.PackerConfigService;
+import cn.reghao.jdkutil.result.Result;
+import cn.reghao.jdkutil.result.ResultStatus;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author reghao
+ * @date 2021-09-17 15:54:16
+ */
+@Service
+public class PackerConfigServiceImpl implements PackerConfigService {
+    private PackerConfigRepository packerRepository;
+    private AppConfigQuery appConfigQuery;
+    private ProjConfigQuery projConfigQuery;
+
+    public PackerConfigServiceImpl(PackerConfigRepository packerRepository, AppConfigQuery appConfigQuery, ProjConfigQuery projConfigQuery) {
+        this.packerRepository = packerRepository;
+        this.appConfigQuery = appConfigQuery;
+        this.projConfigQuery = projConfigQuery;
+    }
+
+    @Override
+    public Result add(PackerConfig packerConfig) {
+        packerRepository.save(packerConfig);
+        return Result.result(ResultStatus.SUCCESS);
+    }
+
+    @Override
+    public Result modify(PackerConfig packerConfig) {
+        packerRepository.save(packerConfig);
+        return Result.result(ResultStatus.SUCCESS);
+    }
+
+    @Override
+    public Result delete(PackerConfig packerConfig) {
+        List<AppConfig> apps = appConfigQuery.findAllByPackerConfig(packerConfig);
+        List<ProjConfig> projs = projConfigQuery.findAllByPackerConfig(packerConfig);
+        if (apps.isEmpty() && projs.isEmpty()) {
+            packerRepository.delete(packerConfig);
+            return Result.result(ResultStatus.SUCCESS);
+        } else {
+            List<String> ids = apps.stream().map(AppConfig::getAppId).collect(Collectors.toList());
+            ids.addAll(projs.stream().map(ProjConfig::getProjId).collect(Collectors.toList()));
+            String msg = packerConfig.getName() + " 删除失败, " + ids.toString() + " 等应用正在使用";
+            return Result.result(ResultStatus.FAIL, msg);
+        }
+    }
+}

+ 115 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/ProjConfigServiceImpl.java

@@ -0,0 +1,115 @@
+package cn.reghao.autodop.dmaster.app.service.config.impl;
+
+import cn.reghao.autodop.dmaster.app.db.crud.config.SharedEntityChecker;
+import cn.reghao.autodop.dmaster.app.db.repository.config.AppConfigRepository;
+import cn.reghao.autodop.dmaster.app.db.repository.config.ProjConfigRepository;
+import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
+import cn.reghao.autodop.dmaster.app.model.po.config.ProjConfig;
+import cn.reghao.autodop.dmaster.app.model.vo.NewApp;
+import cn.reghao.autodop.dmaster.app.service.config.ProjConfigService;
+import cn.reghao.jdkutil.result.Result;
+import cn.reghao.jdkutil.result.ResultStatus;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author reghao
+ * @date 2021-09-17 10:13:46
+ */
+@Service
+public class ProjConfigServiceImpl implements ProjConfigService {
+    private ProjConfigRepository projRepository;
+    private AppConfigRepository appRepository;
+    private SharedEntityChecker sharedEntityChecker;
+
+    public ProjConfigServiceImpl(ProjConfigRepository projRepository,
+                          AppConfigRepository appRepository,
+                          SharedEntityChecker sharedEntityChecker) {
+        this.projRepository = projRepository;
+        this.appRepository = appRepository;
+        this.sharedEntityChecker = sharedEntityChecker;
+    }
+
+    @Override
+    public Result add(ProjConfig proj) {
+        try {
+            Integer id = proj.getId();
+            sharedEntityChecker.checkAndSetBuildConfig(proj);
+            ProjConfig projEntity = projRepository.findByIsDeleteFalseAndProjId(proj.getProjId());
+            if (projEntity != null) {
+                proj.setId(projEntity.getId());
+                proj.setCreateTime(projEntity.getCreateTime());
+                proj.setUpdateTime(LocalDateTime.now());
+            }
+            projRepository.save(proj);
+
+            String msg = id != null ? "更新 " + proj.getProjId() + " 成功"
+                    : "添加 " + proj.getProjId() + " 成功";
+            return Result.result(ResultStatus.SUCCESS, msg);
+        } catch (Exception e) {
+            String msg = e.getMessage();
+            return Result.result(ResultStatus.FAIL, msg);
+        }
+    }
+
+    @Override
+    public Result copy(ProjConfig from, NewApp to) {
+        if (from == null) {
+            String msg = "项目配置不存在";
+            return Result.result(ResultStatus.FAIL, msg);
+        }
+
+        ProjConfig toProj = projRepository.findByIsDeleteFalseAndProjId(to.getNewId());
+        if (toProj != null) {
+            String msg = to.getNewId() + " 已存在";
+            return Result.result(ResultStatus.FAIL, msg);
+        }
+
+        try {
+            toProj = to.proj((ProjConfig) from.clone());
+            add(toProj);
+            return Result.result(ResultStatus.SUCCESS);
+        } catch (CloneNotSupportedException e) {
+            String msg = e.getMessage();
+            return Result.result(ResultStatus.FAIL, msg);
+        }
+    }
+
+    @Override
+    public Result modify(ProjConfig proj) {
+        try {
+            Integer id = proj.getId();
+            sharedEntityChecker.checkAndSetBuildConfig(proj);
+            ProjConfig projEntity = projRepository.findByIsDeleteFalseAndProjId(proj.getProjId());
+            if (projEntity != null) {
+                proj.setId(projEntity.getId());
+                proj.setCreateTime(projEntity.getCreateTime());
+                proj.setUpdateTime(LocalDateTime.now());
+            }
+            projRepository.save(proj);
+
+            String msg = id != null ? "更新 " + proj.getProjId() + " 成功"
+                    : "添加 " + proj.getProjId() + " 成功";
+            return Result.result(ResultStatus.SUCCESS, msg);
+        } catch (Exception e) {
+            String msg = e.getMessage();
+            return Result.result(ResultStatus.FAIL, msg);
+        }
+    }
+
+    @Override
+    public Result delete(ProjConfig proj) {
+        List<AppConfig> apps = appRepository.findAllByProj(proj);
+        if (apps.isEmpty()) {
+            projRepository.delete(proj);
+            return Result.result(ResultStatus.SUCCESS);
+        } else {
+            String appIds = apps.stream().map(AppConfig::getAppId).collect(Collectors.joining());
+            String msg = proj.getProjName() + " 删除失败, " + appIds + " 等应用正在使用";
+            return Result.result(ResultStatus.FAIL, msg);
+        }
+    }
+}

+ 109 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/config/impl/RepoAuthConfigServiceImpl.java

@@ -0,0 +1,109 @@
+package cn.reghao.autodop.dmaster.app.service.config.impl;
+
+import cn.reghao.autodop.dmaster.app.db.crud.config.RepoAuthConfigCrud;
+import cn.reghao.autodop.dmaster.app.db.query.config.AppConfigQuery;
+import cn.reghao.autodop.dmaster.app.db.query.config.ProjConfigQuery;
+import cn.reghao.autodop.dmaster.app.db.query.config.RepoAuthConfigQuery;
+import cn.reghao.autodop.dmaster.app.db.repository.config.build.RepoAuthConfigRepository;
+import cn.reghao.autodop.dmaster.app.model.constant.build.RepoAuthType;
+import cn.reghao.autodop.dmaster.app.model.constant.build.RepoType;
+import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
+import cn.reghao.autodop.dmaster.app.model.po.config.ProjConfig;
+import cn.reghao.autodop.dmaster.app.model.po.config.build.RepoAuthConfig;
+import cn.reghao.autodop.dmaster.app.service.config.RepoAuthConfigService;
+import cn.reghao.jdkutil.result.Result;
+import cn.reghao.jdkutil.result.ResultStatus;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author reghao
+ * @date 2021-09-17 10:16:07
+ */
+@Service
+public class RepoAuthConfigServiceImpl implements RepoAuthConfigService {
+    private RepoAuthConfigQuery repoAuthConfigQuery;
+    private RepoAuthConfigCrud repoAuthConfigCrud;
+    private AppConfigQuery appConfigQuery;
+    private ProjConfigQuery projConfigQuery;
+
+    public RepoAuthConfigServiceImpl(RepoAuthConfigQuery repoAuthConfigQuery, RepoAuthConfigCrud repoAuthConfigCrud,
+                                     AppConfigQuery appConfigQuery, ProjConfigQuery projConfigQuery) {
+        this.repoAuthConfigQuery = repoAuthConfigQuery;
+        this.repoAuthConfigCrud = repoAuthConfigCrud;
+        this.appConfigQuery = appConfigQuery;
+        this.projConfigQuery = projConfigQuery;
+    }
+
+    @Override
+    public Result add(RepoAuthConfig repoAuthConfig) {
+        Result result = valid(repoAuthConfig);
+        if (result.getCode() != ResultStatus.SUCCESS.getCode()) {
+            return result;
+        }
+        repoAuthConfigCrud.save(repoAuthConfig);
+        return result;
+    }
+
+    @Override
+    public Result modify(RepoAuthConfig repoAuthConfig) {
+        Result result = valid(repoAuthConfig);
+        if (result.getCode() != ResultStatus.SUCCESS.getCode()) {
+            return result;
+        }
+        repoAuthConfigCrud.save(repoAuthConfig);
+        return result;
+    }
+
+    private Result valid(RepoAuthConfig repoAuthConfig) {
+        switch (RepoType.valueOf(repoAuthConfig.getType())) {
+            case git:
+                switch (RepoAuthType.valueOf(repoAuthConfig.getAuthType())) {
+                    case ssh:
+                        String rsaPriKey = repoAuthConfig.getRsaPrikey();
+                        if (rsaPriKey.isEmpty() || rsaPriKey.isBlank()) {
+                            return Result.result(ResultStatus.FAIL, "RSA 私钥不能为空");
+                        }
+                        break;
+                    case http:
+                        String username = repoAuthConfig.getUsername();
+                        String password = repoAuthConfig.getPassword();
+                        if (username.isEmpty() || username.isBlank() || password.isEmpty() || password.isBlank()) {
+                            return Result.result(ResultStatus.FAIL, "用户名/密码不能为空");
+                        }
+                        break;
+                    default:
+                        return Result.result(ResultStatus.FAIL, "必须选择 git 的认证类型");
+                }
+                break;
+            case svn:
+                // TODO 暂未实现对 SVN 的验证
+                break;
+            default:
+                return Result.result(ResultStatus.FAIL, "暂不支持除 GIT/SVN 之外的版本管理工具");
+        }
+        return Result.result(ResultStatus.SUCCESS);
+    }
+
+    @Override
+    public Result delete(RepoAuthConfig repoAuthConfig) {
+        List<AppConfig> apps = appConfigQuery.findAllByRepoAuthConfig(repoAuthConfig);
+        List<ProjConfig> projs = projConfigQuery.findAllByRepoAuthConfig(repoAuthConfig);
+        if (apps.isEmpty() && projs.isEmpty()) {
+            repoAuthConfigCrud.delete(repoAuthConfig);
+            return Result.result(ResultStatus.SUCCESS);
+        } else {
+            List<String> ids = apps.stream().map(AppConfig::getAppId).collect(Collectors.toList());
+            ids.addAll(projs.stream().map(ProjConfig::getProjId).collect(Collectors.toList()));
+            String msg = repoAuthConfig.getName() + " 删除失败, " + ids.toString() + " 等应用正在使用";
+            return Result.result(ResultStatus.FAIL, msg);
+        }
+    }
+
+    @Override
+    public RepoAuthConfig get(String name) {
+        return repoAuthConfigQuery.findByName(name);
+    }
+}

+ 10 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/BuildDeployServiceImpl.java → dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/impl/BuildDeployServiceImpl.java

@@ -1,10 +1,19 @@
-package cn.reghao.autodop.dmaster.app.service;
+package cn.reghao.autodop.dmaster.app.service.impl;
+
+import cn.reghao.autodop.dmaster.app.service.BuildDeployService;
+import org.springframework.stereotype.Service;
 
 /**
  * @author reghao
  * @date 2021-09-17 11:30:16
  */
+@Service
 public class BuildDeployServiceImpl implements BuildDeployService {
+    @Override
+    public String buildAndDeploy(String appId) {
+        return "";
+    }
+
     @Override
     public String build(String appId) {
         return "";

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/machine/service/ssh/WebSshImpl.java

@@ -69,7 +69,7 @@ public class WebSshImpl implements WebSsh {
             }
             sendToSsh(sshConnInfo.getChannel(), sshConnData.getCommand());
         } else {
-            log.error("无法处理 {} 操作...", sshConnData.getOps());
+            log.error("无法处理 {} 操作", sshConnData.getOps());
         }
     }
 

+ 5 - 5
dmaster/src/main/java/cn/reghao/autodop/dmaster/machine/service/ssh/ws/WebSocketHandlerImpl.java

@@ -21,7 +21,7 @@ public class WebSocketHandlerImpl implements WebSocketHandler {
 
     @Override
     public void afterConnectionEstablished(WebSocketSession webSocketSession) {
-        log.info("用户 {} 连接 WebSSH...", webSocketSession.getAttributes().get(Keys.USER_UUID));
+        log.info("用户 {} 连接 WebSSH", webSocketSession.getAttributes().get(Keys.USER_UUID));
         webSsh.init(webSocketSession);
     }
 
@@ -29,24 +29,24 @@ public class WebSocketHandlerImpl implements WebSocketHandler {
     public void handleMessage(WebSocketSession webSocketSession, WebSocketMessage<?> webSocketMessage) {
         if (webSocketMessage instanceof TextMessage) {
             TextMessage textMessage = (TextMessage) webSocketMessage;
-            log.info("用户 {} 通过 WebSSH 发送 {} 命令...",
+            log.info("用户 {} 通过 WebSSH 发送 {} 命令",
                     webSocketSession.getAttributes().get(Keys.USER_UUID), webSocketMessage.getPayload());
             webSsh.handleMessage(textMessage.getPayload(), webSocketSession);
         } else if (webSocketMessage instanceof BinaryMessage) {
         } else if (webSocketMessage instanceof PongMessage) {
         } else {
-            log.error("未知类型的 WebSocket 消息...");
+            log.error("未知类型的 WebSocket 消息");
         }
     }
 
     @Override
     public void handleTransportError(WebSocketSession webSocketSession, Throwable throwable) {
-        log.error("WebSocket 数据传输错误...");
+        log.error("WebSocket 数据传输错误");
     }
 
     @Override
     public void afterConnectionClosed(WebSocketSession webSocketSession, CloseStatus closeStatus) {
-        log.info("用户 {} 断开 WebSSH 连接...", webSocketSession.getAttributes().get(Keys.USER_UUID));
+        log.info("用户 {} 断开 WebSSH 连接", webSocketSession.getAttributes().get(Keys.USER_UUID));
         webSsh.close(webSocketSession);
     }
 

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/monitor/service/MonitorScheduler.java

@@ -80,7 +80,7 @@ public class MonitorScheduler {
 
         if (!isJobExist(jobId)) {
             scheduler.scheduleJob(jobDetail, cronTrigger);
-            log.info("添加新定时任务 {}...", jobId);
+            log.info("添加新定时任务 {}", jobId);
         }
     }
 

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/mqttsub/MessageListener.java

@@ -47,7 +47,7 @@ public class MessageListener implements MqttCallback {
     public void messageArrived(String topic, MqttMessage message) {
         try {
             if (message.isDuplicate()) {
-                log.info("重新发送的消息...");
+                log.info("重新发送的消息");
             }
 
             String msg = message.toString();

+ 6 - 6
dmaster/src/main/java/cn/reghao/autodop/dmaster/notification/service/NotifyService.java

@@ -91,14 +91,14 @@ public class NotifyService {
                 }
                 break;
             default:
-                log.error("通知类型不存在...");
+                log.error("通知类型不存在");
         }
     }
 
     public <T> void notify(NotifyGroup notifyGroup, T msg) {
         Notify notify = notifierMap.get(notifyGroup);
         if (notify == null) {
-            log.error("类型为 {}, 账户为 {} 的通知发送器不存在...",
+            log.error("类型为 {}, 账户为 {} 的通知发送器不存在",
                     notifyGroup.getNotifyType(), notifyGroup.getNotifyAccountId());
             return;
         }
@@ -107,27 +107,27 @@ public class NotifyService {
         switch (NotifyType.valueOf(notifyType)) {
             case ding:
                 if (!(msg instanceof DingMsg)) {
-                    log.error("{} 消息格式不正确, 不是 DingMsg...", msg);
+                    log.error("{} 消息格式不正确, 不是 DingMsg", msg);
                 }
                 notifyGroup.getReceivers()
                         .forEach(receiver -> threadPool.execute(new NotifyTask(notify, receiver, msg)));
                 break;
             case email:
                 if (!(msg instanceof EmailMsg)) {
-                    log.error("{} 消息格式不正确, 不是 EmailMsg...", msg);
+                    log.error("{} 消息格式不正确, 不是 EmailMsg", msg);
                 }
                 notifyGroup.getReceivers()
                         .forEach(receiver -> threadPool.execute(new NotifyTask(notify, receiver, msg)));
                 break;
             case sms:
                 if (!(msg instanceof String)) {
-                    log.error("{} 消息格式不正确, 不是 SMS 消息...", msg);
+                    log.error("{} 消息格式不正确, 不是 SMS 消息", msg);
                 }
                 notifyGroup.getReceivers()
                         .forEach(receiver -> threadPool.execute(new NotifyTask(notify, receiver, msg)));
                 break;
             default:
-                log.error("通知类型不存在...");
+                log.error("通知类型不存在");
         }
     }
 

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/rbac/service/MenuServiceImpl.java

@@ -66,7 +66,7 @@ public class MenuServiceImpl implements MenuService {
                 Menu menu2 = menuQuery.findById(pid1);
                 int pid2 = menu2.getPid();
                 if (pid2 != 0) {
-                    return Result.result(ResultStatus.FAIL, "Menu 最多只能有两个 parent,即最多只能有三级菜单...");
+                    return Result.result(ResultStatus.FAIL, "Menu 最多只能有两个 parent,即最多只能有三级菜单");
                 }
             }
         }

+ 5 - 5
dmaster/src/main/java/cn/reghao/autodop/dmaster/rbac/service/UserServiceImpl.java

@@ -55,7 +55,7 @@ public class UserServiceImpl implements UserService {
         String username = user.getUsername();
         User userEntity = userQuery.findByUsername(username);
         if (userEntity != null) {
-            log.error("用户 {} 已存在...", username);
+            log.error("用户 {} 已存在", username);
             return;
         }
 
@@ -81,7 +81,7 @@ public class UserServiceImpl implements UserService {
             setEncryptPassword(userEntity);
             userCrud.save(userEntity);
         } else {
-            log.error("用户不存在...");
+            log.error("用户不存在");
         }
     }
 
@@ -89,7 +89,7 @@ public class UserServiceImpl implements UserService {
     public void modifyUserInfo(UserInfo userInfo) {
         User userEntity = userQuery.findById(userInfo.getUserId());
         if (userEntity == null) {
-            log.error("用户不存在...");
+            log.error("用户不存在");
             return;
         }
 
@@ -103,7 +103,7 @@ public class UserServiceImpl implements UserService {
     public void setUserRoles(UserRole userRole) {
         User userEntity = userQuery.findById(userRole.getUserId());
         if (userEntity == null) {
-            log.error("用户不存在...");
+            log.error("用户不存在");
             return;
         }
 
@@ -118,7 +118,7 @@ public class UserServiceImpl implements UserService {
     public void setUserStatus(Integer userId, Boolean enable) {
         User userEntity = userQuery.findById(userId);
         if (userEntity == null) {
-            log.error("用户不存在...");
+            log.error("用户不存在");
             return;
         }
 

+ 2 - 2
dmaster/src/main/java/cn/reghao/autodop/dmaster/spring/BeforeAppShutdown.java

@@ -41,9 +41,9 @@ public class BeforeAppShutdown implements TomcatConnectorCustomizer, Application
             threadPoolExecutor.shutdown();
             try {
                 if (!threadPoolExecutor.awaitTermination(timeout, TimeUnit.SECONDS)) {
-                    log.warn("应用未在 30s 内优雅关闭,强制关闭应用...");
+                    log.warn("应用未在 30s 内优雅关闭,强制关闭应用");
                 }
-                log.warn("优雅关闭应用...");
+                log.warn("优雅关闭应用");
             } catch (Exception e) {
                 e.printStackTrace();
             }

+ 10 - 9
dmaster/src/main/java/cn/reghao/autodop/dmaster/spring/DmasterLifecycle.java

@@ -8,6 +8,7 @@ import cn.reghao.autodop.common.msg.MsgQueue;
 import cn.reghao.autodop.dmaster.app.db.crud.config.BuildDirCrud;
 import cn.reghao.autodop.dmaster.app.model.po.config.build.BuildDir;
 import cn.reghao.autodop.dmaster.app.model.po.config.build.BuildDirLocal;
+import cn.reghao.autodop.dmaster.app.service.config.BuildDirService;
 import cn.reghao.autodop.dmaster.mqttsub.MessageListener;
 import cn.reghao.autodop.dmaster.sys.db.crud.NodeLogCrud;
 import cn.reghao.autodop.dmaster.util.log.Appenders;
@@ -32,14 +33,14 @@ public class DmasterLifecycle implements ApplicationRunner, DisposableBean {
     private final String topic;
     private final MessageListener messageListener;
     private final DefaultMqttClient mqttClient;
-    private final BuildDirCrud buildDirCrud;
+    private final BuildDirService buildDirService;
 
     public DmasterLifecycle(NodeLogCrud nodeLogCrud, MessageListener messageListener,
-                            BuildDirCrud buildDirCrud, DefaultMqttClient mqttClient) {
+                            BuildDirService buildDirService, DefaultMqttClient mqttClient) {
         this.topic = MsgQueue.dmasterTopic();
         this.messageListener = messageListener;
         this.mqttClient = mqttClient;
-        this.buildDirCrud = buildDirCrud;
+        this.buildDirService = buildDirService;
         initLogger(nodeLogCrud);
     }
 
@@ -53,12 +54,12 @@ public class DmasterLifecycle implements ApplicationRunner, DisposableBean {
     public void run(ApplicationArguments args) throws MqttException {
         subTopic();
         initBuildDir();
-        log.info("autodop-master 初始化完成...");
+        log.info("autodop-master 初始化完成");
     }
 
     @Override
     public void destroy() {
-        log.info("Dmaster 停止...");
+        log.info("Dmaster 停止");
     }
 
     private void subTopic() throws MqttException {
@@ -66,15 +67,15 @@ public class DmasterLifecycle implements ApplicationRunner, DisposableBean {
     }
 
     private void initBuildDir() {
-        log.info("初始化构建目录...");
-        BuildDir buildDir = buildDirCrud.selectByUniqueKey(MachineId.id());
+        log.info("初始化构建目录");
+        BuildDir buildDir = buildDirService.get(MachineId.id());
         if (buildDir == null) {
             buildDir = BuildDirLocal.setDefaultBuildDir();
         } else {
             BuildDirLocal.refreshBuildDir(buildDir);
         }
 
-        log.info("将 {} 写入数据库...", buildDir);
-        buildDirCrud.insert(buildDir);
+        log.info("将 {} 写入数据库", buildDir);
+        buildDirService.add(buildDir);
     }
 }

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/spring/SpringBootUtil.java

@@ -74,7 +74,7 @@ public class SpringBootUtil implements ApplicationContextAware {
         String restart = stop + " && " + start;
 
         try {
-            log.info("重启应用...");
+            log.info("重启应用");
             new ProcessBuilder("sh", "-c", restart).start();
         } catch (IOException e) {
             e.printStackTrace();

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/spring/interceptor/AppIntegrateReinitInterceptor.java

@@ -35,7 +35,7 @@ public class AppIntegrateReinitInterceptor {
         MethodSignature signature = (MethodSignature) joinPoint.getSignature();
         String methodName = signature.getName();
         Object[] args = joinPoint.getArgs();
-        //log.info("拦截 {} 方法...", methodName);
+        //log.info("拦截 {} 方法", methodName);
         /*if ("update".equals(methodName) && args[0] instanceof AppOrchestration) {
             AppOrchestration app = (AppOrchestration) args[0];
             String appId = app.getAppId();

+ 2 - 2
dmaster/src/main/java/cn/reghao/autodop/dmaster/util/AliOss.java

@@ -43,7 +43,7 @@ public class AliOss {
         String ossPath1 = ossProperties.getFolder() + ossPath;
         if (exists(ossPath1)) {
             String dst = ossPath1 + "-" + LocalDate.now().toString();
-            log.info("备份 {} 到 {} ...", ossPath1, dst);
+            log.info("备份 {} 到 {} ", ossPath1, dst);
             move(ossPath1, dst, true);
         }
 
@@ -133,7 +133,7 @@ public class AliOss {
 
                 @Override
                 public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
-                    log.info("无法查看 {} ...", file.toString());
+                    log.info("无法查看 {} ", file.toString());
                     return FileVisitResult.CONTINUE;
                 }