Browse Source

企业回调接口修改

zhouy 1 year ago
parent
commit
9799928f2f

+ 0 - 1
uas-office-qywx-server/build.gradle

@@ -8,6 +8,5 @@ dependencies {
     compile 'org.springframework.boot:spring-boot-starter-data-redis'
     compile 'org.springframework.boot:spring-boot-starter-data-redis'
     compile 'com.h2database:h2'
     compile 'com.h2database:h2'
     compile "$ojdbc"
     compile "$ojdbc"
-    compile "$fasterxml"
     testCompile 'org.springframework.boot:spring-boot-starter-test'
     testCompile 'org.springframework.boot:spring-boot-starter-test'
 }
 }

+ 1 - 0
uas-office-qywx/build.gradle

@@ -4,4 +4,5 @@ dependencies {
     compile 'org.springframework.boot:spring-boot-starter-web'
     compile 'org.springframework.boot:spring-boot-starter-web'
     compile 'org.springframework.boot:spring-boot-starter-jdbc'
     compile 'org.springframework.boot:spring-boot-starter-jdbc'
     compile 'org.springframework.boot:spring-boot-starter-data-redis'
     compile 'org.springframework.boot:spring-boot-starter-data-redis'
+    compile "$fasterxml"
 }
 }

+ 4 - 2
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/manage/controller/QywxCallbackController.java

@@ -42,8 +42,10 @@ public class QywxCallbackController {
      * 消息接收
      * 消息接收
      * */
      * */
     @PostMapping(path = "/qywx/Callback")
     @PostMapping(path = "/qywx/Callback")
-    public String  receiveMessage(@RequestBody String messageXml){
-        qywxCallbackService.callBack(messageXml);
+    public String  receiveMessage(@RequestParam(name = "msg_signature")  String msgSignature,
+                                  @RequestParam(name = "timestamp")  Integer timestamp,
+                                  @RequestParam(name = "nonce")  String nonce, @RequestBody String messageXml){
+        qywxCallbackService.callBack(msgSignature, timestamp, nonce, messageXml);
         return  "success";
         return  "success";
     }
     }
 }
 }

+ 23 - 28
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/manage/entity/QywxCallback.java

@@ -1,50 +1,45 @@
 package com.usoftchina.uas.office.qywx.manage.entity;
 package com.usoftchina.uas.office.qywx.manage.entity;
 
 
-public class QywxCallback {
-    private String SuiteId;
-    private String InfoType;
-    private String SuiteTicket;
-    private String msg_signature;
-
-    public String getSuiteId() {
-        return SuiteId;
-    }
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
 
 
-    public void setSuiteId(String suiteId) {
-        SuiteId = suiteId;
-    }
+public class QywxCallback {
+    @JacksonXmlProperty(localName = "ToUserName")
+    private String toUserName;
+    @JacksonXmlProperty(localName = "AgentID")
+    private String agentID;
+    @JacksonXmlProperty(localName = "Encrypt")
+    private String encrypt;
 
 
-    public String getInfoType() {
-        return InfoType;
+    public String getToUserName() {
+        return toUserName;
     }
     }
 
 
-    public void setInfoType(String infoType) {
-        InfoType = infoType;
+    public void setToUserName(String toUserName) {
+        this.toUserName = toUserName;
     }
     }
 
 
-    public String getSuiteTicket() {
-        return SuiteTicket;
+    public String getAgentID() {
+        return agentID;
     }
     }
 
 
-    public void setSuiteTicket(String suiteTicket) {
-        SuiteTicket = suiteTicket;
+    public void setAgentID(String agentID) {
+        this.agentID = agentID;
     }
     }
 
 
-    public String getMsg_signature() {
-        return msg_signature;
+    public String getEncrypt() {
+        return encrypt;
     }
     }
 
 
-    public void setMsg_signature(String msg_signature) {
-        this.msg_signature = msg_signature;
+    public void setEncrypt(String encrypt) {
+        this.encrypt = encrypt;
     }
     }
 
 
     @Override
     @Override
     public String toString() {
     public String toString() {
         return "QywxCallback{" +
         return "QywxCallback{" +
-                "SuiteId='" + SuiteId + '\'' +
-                ", InfoType='" + InfoType + '\'' +
-                ", SuiteTicket='" + SuiteTicket + '\'' +
-                ", msg_signature='" + msg_signature + '\'' +
+                "toUserName='" + toUserName + '\'' +
+                ", agentID='" + agentID + '\'' +
+                ", encrypt='" + encrypt + '\'' +
                 '}';
                 '}';
     }
     }
 }
 }

+ 15 - 5
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/manage/service/QywxCallbackService.java

@@ -1,6 +1,7 @@
 package com.usoftchina.uas.office.qywx.manage.service;
 package com.usoftchina.uas.office.qywx.manage.service;
 
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
 import com.usoftchina.qywx.sdk.DevSDK;
 import com.usoftchina.qywx.sdk.DevSDK;
 import com.usoftchina.qywx.sdk.ScheduleSdk;
 import com.usoftchina.qywx.sdk.ScheduleSdk;
 import com.usoftchina.qywx.sdk.dto.GetProviderTokenResp;
 import com.usoftchina.qywx.sdk.dto.GetProviderTokenResp;
@@ -22,6 +23,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
 import org.springframework.util.ObjectUtils;
 import org.springframework.util.StringUtils;
 import org.springframework.util.StringUtils;
 
 
+import java.io.IOException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeUnit;
 
 
 @Service
 @Service
@@ -57,20 +59,28 @@ public class QywxCallbackService extends AbstractService {
         return callBackStr;
         return callBackStr;
     }
     }
 
 
-    public String callBack(String messageXml){
+    public String callBack(String msgSignature, Integer timestamp, String nonce, String messageXml){
         //TODO 获取参数回调配置
         //TODO 获取参数回调配置
         String decryptMsg = null;
         String decryptMsg = null;
+        QywxCallback qywxCallback =null;
+        logger.info(messageXml);
+        try {
+            qywxCallback = new XmlMapper().readValue(messageXml, QywxCallback.class);
+            logger.info(qywxCallback.toString());
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
         logger.info("企业微信CallBack POST ");
         logger.info("企业微信CallBack POST ");
-        /*try {
+        try {
             WXBizJsonMsgCrypt wxcpt = new WXBizJsonMsgCrypt(providerConfig.getToken(), providerConfig.getEncodingAESKey(), getCropId());
             WXBizJsonMsgCrypt wxcpt = new WXBizJsonMsgCrypt(providerConfig.getToken(), providerConfig.getEncodingAESKey(), getCropId());
-            decryptMsg = wxcpt.DecryptMsg(msgSignature, timestamp, nonce, jsonMsg);
+
+            decryptMsg = wxcpt.DecryptMsg(msgSignature, String.valueOf(timestamp), nonce, qywxCallback.getEncrypt());
             logger.info("企业微信CallBack POST {}", decryptMsg);
             logger.info("企业微信CallBack POST {}", decryptMsg);
             JSON.parseObject(decryptMsg);
             JSON.parseObject(decryptMsg);
 
 
         } catch (AesException e) {
         } catch (AesException e) {
             e.printStackTrace();
             e.printStackTrace();
-        }*/
-        logger.info(messageXml);
+        }
 
 
         return null;
         return null;
     }
     }