package com.ydtech.modules.admin.controller.wechat; import com.fasterxml.jackson.core.JsonProcessingException; import com.ydtech.core.page.HttpResult; import com.ydtech.modules.admin.components.wechat.customer.response.CustomerListResponse; import com.ydtech.modules.admin.service.WechatCustomerService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.util.List; @Api(tags = "微信业务") @Slf4j @RestController @RequestMapping("/wechat/customer") @RequiredArgsConstructor public class WechatCustomerController { private final WechatCustomerService customerService; @GetMapping(path = "/callback") @ApiOperation(value = "客服回调") public String customerCallback(@RequestParam(value = "msg_signature") String msgSignature, @RequestParam(value = "timestamp") String timestamp, @RequestParam(value = "nonce") String nonce, @RequestParam(value = "echostr") String echoStr) { return customerService.customerCallback(msgSignature, timestamp, nonce, echoStr); } @PostMapping(path = "/callback", consumes = MediaType.TEXT_XML_VALUE, produces = MediaType.TEXT_XML_VALUE) @ApiOperation(value = "客服回调(处理事件发送欢迎语)") public HttpResult customerCallback(@RequestBody String wechatEncrypt) throws JsonProcessingException, WxErrorException { customerService.callbackSendMsgOnEvent(wechatEncrypt); return HttpResult.ok(); } @PostMapping(path = "/list") @ApiOperation(value = "客服列表") public HttpResult> list() throws JsonProcessingException { List list = customerService.list(); return HttpResult.ok(list); } }