From 031eca402975d8f3811d431590698474465d319c Mon Sep 17 00:00:00 2001
From: BAOLH <baolh@yhzhg.cn>
Date: Wed, 19 Feb 2025 06:55:07 +0000
Subject: [PATCH] 企微审批状态回调记录API返回值变更

---
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/impl/WechatSendHistoryServiceImpl.java |   21 +++++++++++++--------
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/Temp.java                                      |    4 ++--
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/WechatSendHistoryService.java          |    2 +-
 3 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/Temp.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/Temp.java
index 828fd72..e67bd40 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/Temp.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/Temp.java
@@ -52,9 +52,9 @@
     @AnonymousGetMapping(value = "/wechat/approval/back")
     @Log("企业微信验证回调URL")
     @ApiOperation("企业微信验证回调URL")
-    public ResponseEntity<Object> approvalBack(@RequestParam(value = "msg_signature") String msgSignature, @RequestParam(value = "timestamp") String timestamp,
+    public void approvalBack(@RequestParam(value = "msg_signature") String msgSignature, @RequestParam(value = "timestamp") String timestamp,
                                                @RequestParam(value = "nonce") String nonce, @RequestParam(value = "echostr") String echostr, HttpServletResponse response){
-        return new ResponseEntity<>(wechatSendHistoryService.approvalBack(msgSignature, timestamp, nonce, echostr, response), HttpStatus.OK);
+        wechatSendHistoryService.approvalBack(msgSignature, timestamp, nonce, echostr, response);
     }
 
     @AnonymousPostMapping(value = "/wechat/approval/back")
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/WechatSendHistoryService.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/WechatSendHistoryService.java
index 3d73661..c92594b 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/WechatSendHistoryService.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/WechatSendHistoryService.java
@@ -91,7 +91,7 @@
      * @param response 响应
      * @return String
      */
-    String approvalBack(String msgSignature, String timestamp, String nonce, String echostr, HttpServletResponse response);
+    void approvalBack(String msgSignature, String timestamp, String nonce, String echostr, HttpServletResponse response);
 
     /**
      * 处理企业微信审批回调事件
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/impl/WechatSendHistoryServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/impl/WechatSendHistoryServiceImpl.java
index 7b40072..86a3487 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/impl/WechatSendHistoryServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/impl/WechatSendHistoryServiceImpl.java
@@ -15,10 +15,8 @@
 */
 package me.zhengjie.modules.temp.service.impl;
 
-import ch.ethz.ssh2.crypto.digest.SHA1;
 import me.zhengjie.modules.temp.domain.WechatSendHistory;
-import me.zhengjie.utils.ValidationUtil;
-import me.zhengjie.utils.FileUtil;
+import me.zhengjie.utils.*;
 import lombok.RequiredArgsConstructor;
 import me.zhengjie.modules.temp.repository.WechatSendHistoryRepository;
 import me.zhengjie.modules.temp.service.WechatSendHistoryService;
@@ -30,11 +28,10 @@
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
-import me.zhengjie.utils.PageUtil;
-import me.zhengjie.utils.QueryHelp;
 
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
+import java.io.PrintWriter;
 import java.util.*;
 import java.io.IOException;
 import javax.servlet.http.HttpServletRequest;
@@ -111,14 +108,22 @@
     }
 
     @Override
-    public String approvalBack(String msgSignature, String timestamp, String nonce, String echostr, HttpServletResponse response) {
+    public void approvalBack(String msgSignature, String timestamp, String nonce, String echostr, HttpServletResponse response) {
         try {
             WXBizJsonMsgCrypt wxcpt = new WXBizJsonMsgCrypt(TOKEN, ENCODING_AES_KEY, CORP_ID);
-            return wxcpt.VerifyURL(msgSignature, timestamp, nonce, echostr);
+            // 设置响应内容类型为纯文本
+            response.setContentType("text/plain; charset=UTF-8");
+            // 获取PrintWriter对象
+            PrintWriter out = response.getWriter();
+            // 直接返回
+            String message = wxcpt.VerifyURL(msgSignature, timestamp, nonce, echostr);
+            out.print(message);
+            // 刷新并关闭PrintWriter
+            out.flush();
+            out.close();
         } catch (Exception e) {
             e.printStackTrace();
         }
-        return null;
     }
 
     @Override

--
Gitblit v1.9.3