|
@@ -24,7 +24,7 @@ import static com.ylx.massage.utils.OtherUtil.verification;
|
|
@Slf4j
|
|
@Slf4j
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/weChat")
|
|
@RequestMapping("/weChat")
|
|
-public class WeChatController{
|
|
|
|
|
|
+public class WeChatController {
|
|
|
|
|
|
private final static String TOKEN = "abcd1234";
|
|
private final static String TOKEN = "abcd1234";
|
|
private final static String ENCODING = "UTF-8";
|
|
private final static String ENCODING = "UTF-8";
|
|
@@ -41,7 +41,7 @@ public class WeChatController{
|
|
|
|
|
|
// private final WeChatUserService weChatUserService;
|
|
// private final WeChatUserService weChatUserService;
|
|
|
|
|
|
-// public WeChatController(WeChatUserService weChatUserService) {
|
|
|
|
|
|
+ // public WeChatController(WeChatUserService weChatUserService) {
|
|
// this.weChatUserService = weChatUserService;
|
|
// this.weChatUserService = weChatUserService;
|
|
// }
|
|
// }
|
|
@Resource
|
|
@Resource
|
|
@@ -52,9 +52,9 @@ public class WeChatController{
|
|
*
|
|
*
|
|
* @param signature 微信加密签名
|
|
* @param signature 微信加密签名
|
|
* @param timestamp 时间戳
|
|
* @param timestamp 时间戳
|
|
- * @param nonce 随机数
|
|
|
|
- * @param echostr 随机字符串
|
|
|
|
- * @param response HTTP响应对象
|
|
|
|
|
|
+ * @param nonce 随机数
|
|
|
|
+ * @param echostr 随机字符串
|
|
|
|
+ * @param response HTTP响应对象
|
|
* @throws Exception 如果处理过程中出现错误
|
|
* @throws Exception 如果处理过程中出现错误
|
|
*/
|
|
*/
|
|
@GetMapping("/verifyToken")
|
|
@GetMapping("/verifyToken")
|
|
@@ -63,9 +63,9 @@ public class WeChatController{
|
|
@RequestParam(value = "nonce") String nonce,
|
|
@RequestParam(value = "nonce") String nonce,
|
|
@RequestParam(value = "echostr") String echostr, HttpServletResponse response) throws Exception {
|
|
@RequestParam(value = "echostr") String echostr, HttpServletResponse response) throws Exception {
|
|
|
|
|
|
- log.info("11111111111111111111111111111111111111111111");
|
|
|
|
|
|
+ log.info("微信Token验证 入参: signature:{},timestamp:{},nonce:{},echostr:{},", signature, timestamp, nonce, echostr);
|
|
// 参数排序
|
|
// 参数排序
|
|
- String[] params = new String[] { timestamp, nonce, TOKEN };
|
|
|
|
|
|
+ String[] params = new String[]{timestamp, nonce, TOKEN};
|
|
Arrays.sort(params);
|
|
Arrays.sort(params);
|
|
|
|
|
|
// 校验成功则响应 echostr,失败则不响应
|
|
// 校验成功则响应 echostr,失败则不响应
|
|
@@ -80,12 +80,12 @@ public class WeChatController{
|
|
@PostMapping("/verifyToken")
|
|
@PostMapping("/verifyToken")
|
|
@Log(title = "公众号pverifyToken", businessType = BusinessType.OTHER)
|
|
@Log(title = "公众号pverifyToken", businessType = BusinessType.OTHER)
|
|
public void pverifyToken(@RequestParam(value = "signature") String signature,
|
|
public void pverifyToken(@RequestParam(value = "signature") String signature,
|
|
- @RequestParam(value = "timestamp") String timestamp,
|
|
|
|
- @RequestParam(value = "nonce") String nonce) {
|
|
|
|
|
|
+ @RequestParam(value = "timestamp") String timestamp,
|
|
|
|
+ @RequestParam(value = "nonce") String nonce) {
|
|
|
|
|
|
log.info("11111111111111111111111111111111111111111111");
|
|
log.info("11111111111111111111111111111111111111111111");
|
|
// 参数排序
|
|
// 参数排序
|
|
- String[] params = new String[] { timestamp, nonce, TOKEN };
|
|
|
|
|
|
+ String[] params = new String[]{timestamp, nonce, TOKEN};
|
|
Arrays.sort(params);
|
|
Arrays.sort(params);
|
|
|
|
|
|
// {
|
|
// {
|