|
@@ -3,6 +3,7 @@ package com.miaxis.system.controller.system;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.miaxis.apple.service.IAppleService;
|
|
|
import com.miaxis.common.core.domain.Response;
|
|
|
+import com.miaxis.common.core.domain.WxUserInfo;
|
|
|
import com.miaxis.common.core.domain.entity.SysMenu;
|
|
|
import com.miaxis.common.core.domain.entity.SysUser;
|
|
|
import com.miaxis.common.core.domain.model.LoginBody;
|
|
@@ -134,7 +135,11 @@ public class SysLoginController
|
|
|
if (wxResult.getErrcode() != null){
|
|
|
throw new CustomException("微信授权无效,请重新授权");
|
|
|
}
|
|
|
- String token = loginService.login(wxResult.getOpenid(),null, StudentLoginTypeEnum.AUTHORIZATION_CODE_LOGIN.getCode());
|
|
|
+ String userInfoStr = wxService.getUserInfo("zh_CN", wxResult.getAccess_token(), wxResult.getOpenid());
|
|
|
+ WxUserInfo wxUserInfo = JSONObject.parseObject(userInfoStr,WxUserInfo.class);
|
|
|
+ ServletUtils.getRequest().setAttribute("headImage",wxUserInfo.getHeadimgurl());
|
|
|
+ ServletUtils.getRequest().setAttribute("nickName",wxUserInfo.getNickname());
|
|
|
+ String token = loginService.login(wxUserInfo.getOpenid(),null, StudentLoginTypeEnum.AUTHORIZATION_CODE_LOGIN.getCode());
|
|
|
TokenDTO tokenDTO = new TokenDTO();
|
|
|
tokenDTO.setToken(token);
|
|
|
tokenDTO.setWxResult(wxResult);
|
|
@@ -146,7 +151,14 @@ public class SysLoginController
|
|
|
@PostMapping("/login/code/test")
|
|
|
@ApiOperation("用户授权码模式登录--测试")
|
|
|
public Response<TokenDTO> testloginByAuthorizationCode(String authorizationCode ){
|
|
|
- String token = loginService.login("oN0Np5sK6JeTRa06hlE4-OkHDlDY",null, StudentLoginTypeEnum.AUTHORIZATION_CODE_LOGIN.getCode());
|
|
|
+ WxUserInfo wxUserInfo = new WxUserInfo();
|
|
|
+ wxUserInfo.setOpenid("oN0Np5sK6JeTRa06hlE4-OkHDlDY");
|
|
|
+ wxUserInfo.setNickname("Sss");
|
|
|
+ wxUserInfo.setSex("0");
|
|
|
+ wxUserInfo.setHeadimgurl("https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83erGMFzKaOmz6cIaA0J1nicWSlBLdLKY46N5CNCoASiajT7Z3RIfPngPhJsjmqsSjGCFibPU4vCtfz3aw/132");
|
|
|
+ ServletUtils.getRequest().setAttribute("headImage",wxUserInfo.getHeadimgurl());
|
|
|
+ ServletUtils.getRequest().setAttribute("nickName",wxUserInfo.getNickname());
|
|
|
+ String token = loginService.login(wxUserInfo.getOpenid(),null, StudentLoginTypeEnum.AUTHORIZATION_CODE_LOGIN.getCode());
|
|
|
TokenDTO tokenDTO = new TokenDTO();
|
|
|
tokenDTO.setToken(token);
|
|
|
return Response.success(tokenDTO) ;
|
|
@@ -160,7 +172,7 @@ public class SysLoginController
|
|
|
public Response<AppleTokenDTO> ioslogin(String identityToken){
|
|
|
try {
|
|
|
JSONObject appleUser = appleService.getAppleUserInfo(identityToken);
|
|
|
- String token = loginService.login(appleUser.getString("sub"),null, StudentLoginTypeEnum.AUTHORIZATION_CODE_LOGIN.getCode());
|
|
|
+ String token = loginService.login(appleUser.getString("sub"),null, StudentLoginTypeEnum.IOS_CODE_LOGIN.getCode());
|
|
|
AppleTokenDTO tokenDTO = new AppleTokenDTO();
|
|
|
tokenDTO.setAppleUserInfo(appleUser);
|
|
|
tokenDTO.setToken(token);
|