微信公众号登录

This commit is contained in:
TinyAnts 2022-09-14 18:11:10 +08:00
parent 65fbd8a3dc
commit c6c7e77adc
2 changed files with 6 additions and 7 deletions

View File

@ -72,8 +72,8 @@ public class LoginController {
@GetMapping("/oaLogin")
public Object oaLogin(@RequestParam Map<String, String> params) {
// log.error("微信公众号 ===================");
// log.error(JSON.toJSONString(params));
iLoginService.officeLogin(params);
log.error(JSON.toJSONString(params));
//iLoginService.officeLogin(params);
return AjaxResult.success();
}

View File

@ -266,15 +266,14 @@ public class LoginServiceImpl implements ILoginService {
public Map<String, Object> officeLogin(Map<String, String> params) {
Assert.notNull(params.get("code"), "code参数缺失!");
String code = params.get("code");
log.error("好好好好来了: " + code);
try {
WxMpService wxMpService = WeChatUtil.official();
WxOAuth2AccessToken wxOAuth2AccessToken = wxMpService.getOAuth2Service().getAccessToken(code);
WxMpUser wxMpUser = wxMpService.getUserService().userInfo(wxOAuth2AccessToken.getAccessToken());
log.error(JSON.toJSONString(wxMpUser));
System.out.println(wxMpUser);
// WxMpUser wxMpUser = wxMpService.getUserService().userInfo(wxOAuth2AccessToken.getAccessToken());
System.out.println(wxOAuth2AccessToken.getOpenId());
} catch (WxErrorException e) {
log.error("错了e"+ e.getError());
System.out.println(e.getError());
}
return null;