WechatCustomerController.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package com.ydtech.modules.admin.controller.wechat;
  2. import com.fasterxml.jackson.core.JsonProcessingException;
  3. import com.ydtech.modules.admin.service.WechatCustomerService;
  4. import io.swagger.annotations.Api;
  5. import io.swagger.annotations.ApiOperation;
  6. import lombok.RequiredArgsConstructor;
  7. import lombok.extern.slf4j.Slf4j;
  8. import org.springframework.http.MediaType;
  9. import org.springframework.web.bind.annotation.*;
  10. @Api(tags = "微信业务")
  11. @Slf4j
  12. @RestController
  13. @RequestMapping("/wechat/customer")
  14. @RequiredArgsConstructor
  15. public class WechatCustomerController {
  16. private final WechatCustomerService customerService;
  17. @GetMapping(path = "/callback")
  18. @ApiOperation(value = "客服回调")
  19. public String customerCallback(@RequestParam(value = "msg_signature") String msgSignature,
  20. @RequestParam(value = "timestamp") String timestamp,
  21. @RequestParam(value = "nonce") String nonce,
  22. @RequestParam(value = "echostr") String echoStr) {
  23. return customerService.customerCallback(msgSignature, timestamp, nonce, echoStr);
  24. }
  25. @PostMapping(path = "/callback", consumes = MediaType.TEXT_XML_VALUE, produces = MediaType.TEXT_XML_VALUE)
  26. @ApiOperation(value = "客服回调(处理事件发送欢迎语)")
  27. public void customerCallback(@RequestBody String wechatEncrypt) throws JsonProcessingException {
  28. customerService.callbackSendMsgOnEvent(wechatEncrypt);
  29. }
  30. }