From daaef7efd5acf15fb756c124c6d3366b52e10bb5 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Mon, 10 Oct 2022 09:09:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8C=BA=E5=9F=9F=E5=85=AC?= =?UTF-8?q?=E5=8F=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cweb/controller/WechatController.java | 38 ++++++++++++-- .../com/v1/controller/WxMsgController.java | 52 +++++++++---------- v1/src/main/resources/dev/application.yml | 26 ++++++++++ 3 files changed, 86 insertions(+), 30 deletions(-) diff --git a/hai-cweb/src/main/java/com/cweb/controller/WechatController.java b/hai-cweb/src/main/java/com/cweb/controller/WechatController.java index 55c72c1b..45c09847 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/WechatController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/WechatController.java @@ -15,10 +15,7 @@ import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.*; -import com.hai.common.utils.HttpsUtils; -import com.hai.common.utils.IDGenerator; -import com.hai.common.utils.RedisUtil; -import com.hai.common.utils.ResponseMsgUtil; +import com.hai.common.utils.*; import com.hai.entity.HighUser; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; @@ -371,4 +368,37 @@ public class WechatController { return ResponseMsgUtil.exception(e); } } + + @RequestMapping(value = "/verifyWx", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "微信签名") + public ResponseData verifyWx(@RequestParam(value = "url", required = true) String url) { + + try { + + Map params = new HashMap<>(); + params.put("appid", SysConst.getSysConfig().getWxH5AppId()); + params.put("secret", SysConst.getSysConfig().getWxH5AppSecret()); + params.put("grant_type", "client_credential"); + + JSONObject accessTokenObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/token", params); + + Map map = new HashMap<>(); + map.put("noncestr",WxUtils.makeNonStr()); + map.put("jsapi_ticket",accessTokenObject.getString("ticket")); + map.put("timestamp", new Date().getTime()); + map.put("url",url); + + Map objectMap = new HashMap<>(); + objectMap.put("appId" , params.get("appId")); + objectMap.put("timestamp" , map.get("timestamp")); + objectMap.put("nonceStr" , map.get("nonceStr")); + objectMap.put("signature" , WxUtils.getSHA1(map)); + + return ResponseMsgUtil.success(objectMap); + } catch (Exception e) { + return null; + } + + } } diff --git a/v1/src/main/java/com/v1/controller/WxMsgController.java b/v1/src/main/java/com/v1/controller/WxMsgController.java index ecb91f91..e6ebb068 100644 --- a/v1/src/main/java/com/v1/controller/WxMsgController.java +++ b/v1/src/main/java/com/v1/controller/WxMsgController.java @@ -251,32 +251,32 @@ public class WxMsgController { } - @RequestMapping(value = "/verifyWx", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "微信签名") - public String verifyWx() { - - try { - - Map params = new HashMap<>(); - params.put("appid", SysConst.getSysConfig().getWxH5AppId()); - params.put("secret", SysConst.getSysConfig().getWxH5AppSecret()); - params.put("grant_type", "client_credential"); - - JSONObject accessTokenObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/token", params); - - Map map = new HashMap<>(); - map.put("noncestr","Wm3WZYTPz0wzccnW"); - map.put("jsapi_ticket",accessTokenObject.getString("ticket")); - map.put("timestamp","1414587457"); - map.put("url","http://mp.weixin.qq.com?params=value"); - - return WxUtils.getSHA1(map); - } catch (Exception e) { - return null; - } - - } +// @RequestMapping(value = "/verifyWx", method = RequestMethod.GET) +// @ResponseBody +// @ApiOperation(value = "微信签名") +// public String verifyWx() { +// +// try { +// +// Map params = new HashMap<>(); +// params.put("appid", SysConst.getSysConfig().getWxH5AppId()); +// params.put("secret", SysConst.getSysConfig().getWxH5AppSecret()); +// params.put("grant_type", "client_credential"); +// +// JSONObject accessTokenObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/token", params); +// +// Map map = new HashMap<>(); +// map.put("noncestr","Wm3WZYTPz0wzccnW"); +// map.put("jsapi_ticket",accessTokenObject.getString("ticket")); +// map.put("timestamp","1414587457"); +// map.put("url","http://mp.weixin.qq.com?params=value"); +// +// return WxUtils.getSHA1(map); +// } catch (Exception e) { +// return null; +// } +// +// } } diff --git a/v1/src/main/resources/dev/application.yml b/v1/src/main/resources/dev/application.yml index d86cbae9..f49193a0 100644 --- a/v1/src/main/resources/dev/application.yml +++ b/v1/src/main/resources/dev/application.yml @@ -53,6 +53,11 @@ spring: #MQTT默认的消息推送主题,实际可在调用接口是指定 # default: # topic: topic + rocketmq: + name-server: 139.159.177.244:9876 + producer: + #必须指定group + group: default-group #配置日期返回至前台为时间戳 jackson: serialization: @@ -62,6 +67,27 @@ mybatis: - classpath*:sqlmap*/*.xml type-aliases-package: org.springboot.sample.entity + jetcache: + statIntervalMinutes: 15 + areaInCacheName: false + local: + default: + type: linkedhashmap + keyConvertor: fastjson + remote: + default: + type: redis + host: 139.159.177.244 + port: 36379 + password: HF123456.Redis + keyConvertor: fastjson + broadcastChannel: projectA + valueEncoder: java + valueDecoder: java + poolConfig: + minIdle: 5 + maxIdle: 20 + maxTotal: 50 pagehelper: helperDialect: mysql