微信授权接口新增
This commit is contained in:
parent
c8e744c0fc
commit
ca93795641
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue