孙永军 пре 2 година
родитељ
комит
3bcf23743c

+ 40 - 2
src/main/java/com/sxtvs/open/api/h5template/service/impl/H5OperateServiceImpl.java

@@ -1,16 +1,24 @@
 package com.sxtvs.open.api.h5template.service.impl;
 
 import cn.hutool.core.util.IdUtil;
+
 import com.sxtvs.open.api.h5template.entity.H5Operate;
-import com.sxtvs.open.api.h5template.entity.H5OperateForm;
-import com.sxtvs.open.api.h5template.entity.H5Template;
 import com.sxtvs.open.api.h5template.mapper.H5OperateMapper;
 import com.sxtvs.open.api.h5template.service.IH5OperateService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.sxtvs.open.core.sls.AliyunLogger;
 import jakarta.annotation.Resource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.net.URI;
+
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
 import java.time.LocalDateTime;
 
 /**
@@ -27,6 +35,15 @@ public class H5OperateServiceImpl extends ServiceImpl<H5OperateMapper, H5Operate
     @Resource
     private H5OperateFormServiceImpl h5OperateFormService;
 
+    @Value("${build.url}")
+    private String buildUrl;
+
+    @Resource
+    private AliyunLogger logger;
+
+    @Autowired
+    private StringRedisTemplate redisTemplate;
+
     @Transactional
     public void store(H5Operate h5Operate){
         h5Operate.setH5Status(0);
@@ -40,6 +57,9 @@ public class H5OperateServiceImpl extends ServiceImpl<H5OperateMapper, H5Operate
             h5OperateFormService.store(h5Operate);
             save(h5Operate);
         }
+
+        //通知编译
+        this.syncGet(buildUrl);
     }
 
     @Transactional
@@ -48,6 +68,24 @@ public class H5OperateServiceImpl extends ServiceImpl<H5OperateMapper, H5Operate
         h5Operate.setUpdateTime(LocalDateTime.now());
         h5OperateFormService.update(h5Operate);
         updateById(h5Operate);
+        //通知编译
+        this.syncGet(buildUrl);
+    }
+
+    private void syncGet(String url){
+        new Thread(() -> {
+            HttpClient client = HttpClient.newHttpClient();
+            HttpRequest request = HttpRequest.newBuilder()
+                    .uri(URI.create(url))
+                    .build();
+            client.sendAsync(request, HttpResponse.BodyHandlers.ofString())
+                    .thenApply(HttpResponse::body)
+                    .thenAccept(s -> {
+                        logger.info("build", s);
+                    })
+                    .join();
+        }).start();
+
     }
 
 

+ 4 - 1
src/main/resources/application.yml

@@ -67,4 +67,7 @@ elasticsearch:
   apikey: RGM0S1hvWUI0aUtoa3RTR245SHo6cm9wZDBOUVBTaFM4UENHZE9BTUt3dw==
   max-total: 8
   max-idle: 8
-  min-idle: 1
+  min-idle: 1
+
+build:
+  url: http://10.30.162.32:8807/build/c30e42cb98787aea1