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

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

@ -46,4 +46,12 @@ public class UserRespDTO implements Serializable {
@ApiModelProperty(value = "手机号") @ApiModelProperty(value = "手机号")
private String mobile; 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.setLastLoginIp(loginUserInfo.getLastLoginIp());
} }
userInfo.setWxId(loginUserInfo.getWxId());
if (!UserStatusEnum.ENABLE.getStatus().equals(userInfo.getStatus())) { if (!UserStatusEnum.ENABLE.getStatus().equals(userInfo.getStatus())) {
return null; return null;
} }

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

Loading…
Cancel
Save