From ca9379564103da710dfb653a20e03c6ef2e66f5c Mon Sep 17 00:00:00 2001 From: clunt Date: Mon, 31 Oct 2022 09:04:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=8E=88=E6=9D=83=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ghy/web/controller/tool/WxController.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/tool/WxController.java b/ghy-admin/src/main/java/com/ghy/web/controller/tool/WxController.java index 88abe364..ef5c4a67 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/tool/WxController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/tool/WxController.java @@ -6,6 +6,7 @@ import com.ghy.common.core.controller.BaseController; import com.ghy.common.core.domain.AjaxResult; import com.ghy.common.exception.ServiceException; import com.ghy.common.utils.ExceptionUtil; +import com.ghy.common.utils.StringUtils; import com.ghy.common.utils.WxUtils; import com.ghy.common.utils.http.HttpUtils; import com.ghy.customer.domain.Customer; @@ -111,6 +112,22 @@ public class WxController extends BaseController { } } + @GetMapping("/token/code") + @ResponseBody + public JSONObject tokenCode(HttpServletRequest request) throws IOException{ + JSONObject wxUser = WxUtils.getOpenid(request.getParameter("code"), "wx404f2439a8c24e15", "49ade04a817067fe2d65ab2f17afce75"); + String openId = wxUser.getString("openid"); + if(StringUtils.isNotEmpty(openId)){ + String questionUrl = "https://www.opsoul.com:8883/exam/question/details/list/"; + JSONObject result = new JSONObject(); + result.put("data", HttpUtils.sendGet(questionUrl + openId)); + result.put("openid", openId); + return result; + }else { + return null; + } + } + @GetMapping("/auth/phone") @ResponseBody public AjaxResult authPhone(HttpServletRequest request){ @@ -155,7 +172,7 @@ public class WxController extends BaseController { @ResponseBody public String openId(HttpServletRequest request) throws Exception { String code = request.getParameter("code"); - JSONObject wxUser = WxUtils.getOpenid(code, wxConfig.getAppId(), wxConfig.getSecret()); + JSONObject wxUser = WxUtils.getOpenid(code, "wx404f2439a8c24e15", "49ade04a817067fe2d65ab2f17afce75"); return wxUser.getString("openid"); }