tuonina 5 lat temu
rodzic
commit
93fe7550d5

+ 7 - 4
tuon-qywx/src/main/kotlin/cn/tonyandmoney/tuon/qywx/controller/QywxController.kt

@@ -19,11 +19,12 @@ import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.beans.factory.annotation.Qualifier
 import org.springframework.core.io.buffer.DataBufferUtils
 import org.springframework.http.server.reactive.ServerHttpRequest
+import org.springframework.stereotype.Controller
 import org.springframework.web.bind.annotation.*
 import org.springframework.web.server.ServerWebExchange
 import reactor.core.publisher.Mono
 
-@RestController
+@Controller
 @RequestMapping("/qywx")
 class QywxController {
 
@@ -43,6 +44,7 @@ class QywxController {
     private lateinit var objectMapper: ObjectMapper
 
     @GetMapping("/user")
+    @ResponseBody
     fun getUserInfo(@RequestParam("code", required = false) code: String?,
                     @RequestParam("agentId") agentId: String,
                     exchange: ServerWebExchange): Mono<BaseResp<IUser>> {
@@ -70,7 +72,7 @@ class QywxController {
     }
 
     /**
-     * 接收消息,返回的数据类型./
+     * 接收消息,返回的数据类型
      */
     @PostMapping("/config/message", produces = ["application/xml;charset=UTF-8"])
     fun configUserMessage(@RequestParam("msg_signature") signature: String,
@@ -83,9 +85,10 @@ class QywxController {
                     Mono.create<String> {
                         val bytes = ByteArray(dataBuffer.readableByteCount())
                         dataBuffer.read(bytes)
-                        logger.info(msgMarker, "content:{}", String(bytes))
+
                         val wxMsg = objectMapper.readValue<WxMsg>(bytes, WxMsg::class.java)
                         val content = wxBizMsgCrypt.decryptMsg(signature, timestamp, nonce, wxMsg.encrypt)
+                        logger.info(msgMarker, "content:{}", content)
                         val resp = ""
                         if ("值班" == content) {
 
@@ -101,7 +104,7 @@ class QywxController {
     /**
      * 验证URL
      */
-    @GetMapping("/config/message")
+    @GetMapping("/config/message",produces = ["application/xml;charset=UTF-8"])
     fun verifySignature(@RequestParam("msg_signature") signature: String,
                         @RequestParam("timestamp") timestamp: String,
                         @RequestParam("nonce") nonce: String,