微信公众号登录
This commit is contained in:
parent
65fbd8a3dc
commit
c6c7e77adc
|
|
@ -72,8 +72,8 @@ public class LoginController {
|
||||||
@GetMapping("/oaLogin")
|
@GetMapping("/oaLogin")
|
||||||
public Object oaLogin(@RequestParam Map<String, String> params) {
|
public Object oaLogin(@RequestParam Map<String, String> params) {
|
||||||
// log.error("微信公众号 ===================");
|
// log.error("微信公众号 ===================");
|
||||||
// log.error(JSON.toJSONString(params));
|
log.error(JSON.toJSONString(params));
|
||||||
iLoginService.officeLogin(params);
|
//iLoginService.officeLogin(params);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -266,15 +266,14 @@ public class LoginServiceImpl implements ILoginService {
|
||||||
public Map<String, Object> officeLogin(Map<String, String> params) {
|
public Map<String, Object> officeLogin(Map<String, String> params) {
|
||||||
Assert.notNull(params.get("code"), "code参数缺失!");
|
Assert.notNull(params.get("code"), "code参数缺失!");
|
||||||
String code = params.get("code");
|
String code = params.get("code");
|
||||||
log.error("好好好好来了: " + code);
|
|
||||||
try {
|
try {
|
||||||
WxMpService wxMpService = WeChatUtil.official();
|
WxMpService wxMpService = WeChatUtil.official();
|
||||||
WxOAuth2AccessToken wxOAuth2AccessToken = wxMpService.getOAuth2Service().getAccessToken(code);
|
WxOAuth2AccessToken wxOAuth2AccessToken = wxMpService.getOAuth2Service().getAccessToken(code);
|
||||||
WxMpUser wxMpUser = wxMpService.getUserService().userInfo(wxOAuth2AccessToken.getAccessToken());
|
|
||||||
log.error(JSON.toJSONString(wxMpUser));
|
// WxMpUser wxMpUser = wxMpService.getUserService().userInfo(wxOAuth2AccessToken.getAccessToken());
|
||||||
System.out.println(wxMpUser);
|
System.out.println(wxOAuth2AccessToken.getOpenId());
|
||||||
} catch (WxErrorException e) {
|
} catch (WxErrorException e) {
|
||||||
log.error("错了e"+ e.getError());
|
|
||||||
System.out.println(e.getError());
|
System.out.println(e.getError());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue