|
@@ -1,97 +0,0 @@
|
|
|
-package com.miaxis.app.controller.wx;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.miaxis.common.constant.Constants;
|
|
|
-import com.miaxis.common.core.domain.Response;
|
|
|
-import com.miaxis.common.utils.wx.SignUtil;
|
|
|
-import com.miaxis.wx.service.IWxGzhService;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-import lombok.RequiredArgsConstructor;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-
|
|
|
-/**
|
|
|
- * 微信公众号相关
|
|
|
- * @author wwl
|
|
|
- * @version 1.0
|
|
|
- * @date 2021/10/26 9:28
|
|
|
- */
|
|
|
-@RestController
|
|
|
-@RequiredArgsConstructor
|
|
|
-@RequestMapping(Constants.OPEN_PREFIX + "/wx/gzh")
|
|
|
-@Api(tags={"【H5-wx微信公众号相关】"})
|
|
|
-@Slf4j
|
|
|
-public class WxgzhController {
|
|
|
-
|
|
|
- private final IWxGzhService wxGzhService;
|
|
|
-
|
|
|
-
|
|
|
- private final HttpServletRequest request;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取微信验签
|
|
|
- * @param request
|
|
|
- * @return
|
|
|
- */
|
|
|
- @GetMapping(value = "/notifyMsg")
|
|
|
- @ApiOperation("获取微信验签")
|
|
|
- public String checkSign(HttpServletRequest request) {
|
|
|
- log.info("-----------进入---------");
|
|
|
- try {
|
|
|
- String signature = request.getParameter("signature");
|
|
|
- String timestamp = request.getParameter("timestamp");
|
|
|
- String nonce = request.getParameter("nonce");
|
|
|
- String echostr = request.getParameter("echostr");
|
|
|
- log.info("本身" + signature);
|
|
|
- log.info("-----------微信验签---------");
|
|
|
- return SignUtil.checkSignature(signature, timestamp, nonce) == true ? echostr : null;
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("验证公众号token失败", e);
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 处理服务器推送消息
|
|
|
- * @param request
|
|
|
- * @return
|
|
|
- */
|
|
|
- @PostMapping(value = "/notifyMsg")
|
|
|
- @ApiOperation("处理服务器推送消息")
|
|
|
- public String dealNotify(HttpServletRequest request) {
|
|
|
- log.info("-----------进入---------");
|
|
|
- try {
|
|
|
- log.info("-----------推送消息处理---------");
|
|
|
- return wxGzhService.handlePublicMsg(request);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("处理推送消息失败", e);
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取公众号访问jspapi 需要的参数
|
|
|
- * @return
|
|
|
- */
|
|
|
- @GetMapping(value = "/jspapi")
|
|
|
- @ApiOperation("获取jspapi参数")
|
|
|
- public Response<JSONObject> getJspapi(String url) {
|
|
|
-
|
|
|
- return Response.success(wxGzhService.getJspapi(url));
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-}
|