fix 小程序绑定失效的bug

fix 选择小程序一键登录失败的bug
This commit is contained in:
damonyuan 2024-11-09 23:30:54 +08:00
parent 1397ad8917
commit d2e42a5cb6
2 changed files with 26 additions and 6 deletions

View File

@ -77,7 +77,7 @@ public class LoginController {
@PostMapping("/mnpLogin")
@ApiOperation(value="微信登录")
public AjaxResult<LoginTokenVo> mnpLogin(@Validated @RequestBody LoginCodeValidate loginCodeValidate) {
Integer terminal = LikeFrontThreadLocal.getTerminal();
Integer terminal = ClientEnum.MNP.getCode();
String code = loginCodeValidate.getCode();
@ -145,4 +145,14 @@ public class LoginController {
iUserService.bindOa(BindOaValidate, userId);
return AjaxResult.success();
}
@PostMapping("/mnpAuthBind")
@ApiOperation(value="绑定小程序")
public AjaxResult<Object> mnpAuthBind(@Validated @RequestBody UserBindWechatValidate BindOaValidate) {
Integer userId = LikeFrontThreadLocal.getUserId();
iUserService.bindMnp(BindOaValidate, userId);
return AjaxResult.success();
}
}

View File

@ -347,11 +347,21 @@ public class LoginServiceImpl implements ILoginService {
*/
private LoginTokenVo __wxLoginHandle(String openId, String unionId, String avatar, String nickname, Integer terminal) {
// 查询授权
UserAuth userAuth = userAuthMapper.selectOne(new QueryWrapper<UserAuth>()
QueryWrapper queryWrapper = new QueryWrapper<UserAuth>();
if (StringUtils.equals(unionId, "0") == false) {
queryWrapper = new QueryWrapper<UserAuth>()
.nested(wq->wq
.eq("unionid", unionId).or()
.eq("openid", openId)
).last("limit 1"));
).last("limit 1");
} else {
queryWrapper = new QueryWrapper<UserAuth>()
.nested(wq->wq
.eq("openid", openId)
).last("limit 1");
}
UserAuth userAuth = userAuthMapper.selectOne(queryWrapper);
// 查询用户
User user = null;