fix wechat login

main
wangqing 8 months ago
parent 3dfa632fc3
commit 1160f43bcc

@ -141,7 +141,6 @@ public class LoginController extends BaseController {
}
@ApiOperation(value = "2.1 appleId登录/注册", notes = "成功后返回authorization")
@PostMapping("/appleIdLogin")
@GlobalInterceptor(frequencyType = RequestFrequencyTypeEnum.HOUR, requestFrequencyThreshold = 12)
public Result<String> appleIdLogin(HttpServletRequest request,@VerifyParam AppleLoginReq appleLoginReq) {
@ -178,7 +177,6 @@ public class LoginController extends BaseController {
@ApiOperation(value = "2.2 微信wxId登录/注册", notes = "成功后返回authorization")
@PostMapping("/wxIdLogin")
@GlobalInterceptor(frequencyType = RequestFrequencyTypeEnum.HOUR, requestFrequencyThreshold = 12)
public Result<String> wxIdLogin(HttpServletRequest request,@VerifyParam WeChatLoginReq weChatLoginReq) {
// 如果有手机号,是首次微信登录时绑定流程

@ -117,6 +117,8 @@ public class MyController extends BaseController {
UserInfo user = userInfoService.findById(userLoginDto.getUserId());
UserRespDTO userRespDTO = getUserRespDTO(user, true, Collections.emptySet());
userRespDTO.setMobile(user.getMobile());
userRespDTO.setWxId(user.getWxId());
userRespDTO.setAppleId(user.getAppleId());
return Result.success(userRespDTO);
}
@ -495,9 +497,9 @@ public class MyController extends BaseController {
UserInfo userInfo2 = userInfoService.findById(userId);
if (null != userInfo1) {
// 如果绑定的手机号已存在
userInfo1.setAppleId(userInfo2.getAppleId());
userInfoService.update(userInfo1);
userInfoService.deleteById(userId);
userInfo2.setMobile(loginReq.getMobile());
userInfoService.update(userInfo2);
userInfoService.deleteById(userInfo1.getId());
return Result.success();
}

@ -46,4 +46,12 @@ public class UserRespDTO implements Serializable {
@ApiModelProperty(value = "手机号")
private String mobile;
@ApiModelProperty(value = "apple id")
private String appleId;
@ApiModelProperty(value = "微信 wx id")
private String wxId;
}

@ -315,6 +315,7 @@ public class UserInfoService {
userInfo.setLastLoginIp(loginUserInfo.getLastLoginIp());
}
userInfo.setWxId(loginUserInfo.getWxId());
if (!UserStatusEnum.ENABLE.getStatus().equals(userInfo.getStatus())) {
return null;
}

@ -110,13 +110,13 @@ public class WeChatAouth2Service {
redisTemplate.opsForValue().set(loginReq.getCode(),accessToken.getOpenid(),10,TimeUnit.MINUTES);
return Result.failed(StatusCode.WECHAT_MOBILE_UNBINDED);
}
UserInfo loginUserInfo = new UserInfo();
// UserInfo loginUserInfo = new UserInfo();
// loginUserInfo.setWxId(accessToken.getOpenid());
// loginUserInfo.setMobile(loginReq.getMobile());
loginUserInfo.setLastUseDeviceId(loginReq.getDeviceId());
loginUserInfo.setLastUseDeviceBrand(loginReq.getDeviceBrand());
loginUserInfo.setLastLoginIp(ipAddress);
String token = userInfoService.wechatlogin(loginUserInfo);
userInfo.setLastUseDeviceId(loginReq.getDeviceId());
userInfo.setLastUseDeviceBrand(loginReq.getDeviceBrand());
userInfo.setLastLoginIp(ipAddress);
String token = userInfoService.wechatlogin(userInfo);
return Result.success(token);
}

Loading…
Cancel
Save