24282 1 tahun lalu
induk
melakukan
ee2af78aa8

+ 46 - 0
src/main/java/com/fjhx/controller/SystemMenuController.java

@@ -0,0 +1,46 @@
+package com.fjhx.controller;
+
+import com.alibaba.fastjson2.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * <p>
+ * 目录 前端控制器
+ * </p>
+ *
+ * @author zlj
+ * @since 2023-08-09
+ */
+@Slf4j
+@RestController
+@RequestMapping("/open")
+public class SystemMenuController {
+
+    private static final RestTemplate restTemplate = new RestTemplate();
+
+    @Value("${byteSailing.dingding.url}")
+    private String url;
+
+    @PostMapping(value = "/dingCallback")
+    public Object dingCallback(
+            @RequestParam(value = "signature") String signature,
+            @RequestParam(value = "timestamp") Long timestamp,
+            @RequestParam(value = "nonce") String nonce,
+            @RequestBody(required = false) JSONObject body) {
+
+        String param = "?signature=" + signature + "&timestamp=" + timestamp + "&nonce=" + nonce;
+
+        try {
+            String result = restTemplate.postForObject(url + param, body, String.class);
+            return JSONObject.parseObject(result);
+        } catch (Exception e) {
+            log.error("钉钉回调转发失败", e);
+            return "fail";
+        }
+
+    }
+
+}

+ 3 - 0
src/main/resources/application-prod.yml

@@ -0,0 +1,3 @@
+byteSailing:
+  dingding:
+    url: http://139.159.251.109:81/prod-api/open/dingCallback

+ 3 - 0
src/main/resources/application-test.yml

@@ -0,0 +1,3 @@
+byteSailing:
+  dingding:
+    url: http://121.37.194.75:20006/test-api/open/dingCallback

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

@@ -1,2 +1,6 @@
 server:
-  port: 8081
+  port: 8081
+
+spring:
+  profiles:
+    active: test