From efaa975d89a6cc2ca16916834eba19f54f0229f8 Mon Sep 17 00:00:00 2001
From: zhanglin8526 <852614290@qq.com>
Date: 星期六, 26 八月 2023 16:38:04 +0800
Subject: [PATCH] 分账
---
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/conslole/QYWXCallBackController.java | 36 ++++++++++++++++++++++++++++++------
1 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/conslole/QYWXCallBackController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/conslole/QYWXCallBackController.java
index e18eb1b..3c8a337 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/conslole/QYWXCallBackController.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/conslole/QYWXCallBackController.java
@@ -1,10 +1,16 @@
package com.ruoyi.system.controller.conslole;
-import com.esotericsoftware.minlog.Log;
+import com.ruoyi.common.core.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
+import lombok.extern.log4j.Log4j2;
+import me.chanjar.weixin.common.util.crypto.WxCryptUtil;
import org.apache.commons.io.IOUtils;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -19,13 +25,15 @@
@Api(value = "企业微信通知控制", tags = "企业微信通知控制", description = "企业微信通知控制")
@RestController
@RequestMapping("/qywx")
+@Log4j2
public class QYWXCallBackController {
+ @Autowired
+ private WxCryptUtil wxCryptUtil;
@ApiOperation(value = "消息与事件接收配置")
- @RequestMapping(value = "/qywxNotify",
- method = RequestMethod.POST,consumes = "text/xml",produces = "text/xml;charset=utf-8")
- public String wechatPlatformEvent(@PathVariable String APPID,
+ @RequestMapping(value = "/qywxNotify", method = {RequestMethod.GET,RequestMethod.POST})
+ public String wechatPlatformEvent(@RequestBody(required = false) String body,
HttpServletRequest request,
HttpServletResponse response
) throws Exception {
@@ -33,9 +41,25 @@
String timestamp = request.getParameter("timestamp");
String signature = request.getParameter("signature");
String msgSignature = request.getParameter("msg_signature");
+ String echostr = request.getParameter("echostr");
String encType = request.getParameter("encrypt_type");
String xml = IOUtils.toString(request.getReader());
- Log.info("企业微信回调"+xml);
+ log.info("企业微信回调参数nonce"+nonce);
+ log.info("企业微信回调参数timestamp"+timestamp);
+ log.info("企业微信回调参数signature"+signature);
+ log.info("企业微信回调参数msgSignature"+msgSignature);
+ log.info("企业微信回调参数encType"+encType);
+ log.info("企业微信回调参数xml"+xml);
+ log.info("企业微信回调参数echostr"+echostr);
+ if(StringUtils.isNotBlank(msgSignature)&&StringUtils.isNotBlank(timestamp)&&StringUtils.isNotBlank(nonce)&&StringUtils.isNotBlank(xml)){
+ String reponseStr = wxCryptUtil.decryptXml(msgSignature,timestamp,nonce,xml);
+ log.info("企业微信回调参数xml解析"+reponseStr);
+ }
+ if(StringUtils.isNotBlank(msgSignature)&&StringUtils.isNotBlank(timestamp)&&StringUtils.isNotBlank(nonce)&&StringUtils.isNotBlank(echostr)){
+ String reponseStr = wxCryptUtil.decryptXml(msgSignature,timestamp,nonce,echostr);
+ log.info("企业微信回调参数xml解析"+reponseStr);
+ return reponseStr;
+ }
return "SUCCESS";
}
}
--
Gitblit v1.7.1