| | |
| | | , String imgUrl, String nickname,String userType){ |
| | | List<String> userTypes = new ArrayList<>(); |
| | | userTypes.add(userType); |
| | | User user = userMapper.getByOpenID(openId,userTypes); |
| | | if(user == null){ |
| | | List<User> userList = userMapper.getByOpenID(openId,userTypes); |
| | | if(CollectionUtils.isEmpty(userList)){ |
| | | throw new ValidationException("请注册账号后至\"个人中心-绑定微信\"后再使用微信登录"); |
| | | } |
| | | User user=userList.get(0); |
| | | // user.setNickName(nickname); |
| | | user.setNickName(user.getLoginName()); |
| | | user.setPicture(imgUrl); |
| | |
| | | } |
| | | |
| | | public void bindWechat(String userId, String openId, String unionId, String sessionKey, BindWechatDTO dto) { |
| | | // 查看微信是否已经绑定过用户 |
| | | |
| | | User user = userMapper.selectById(userId); |
| | | if(ObjectUtils.isEmpty(user)){ |
| | | throw new ValidationException("当前用户不存在"); |
| | | } |
| | | |
| | | |
| | | List<User> userList=wechatMapper.selectUserByOpenId(openId,user.getType()); |
| | | if(!CollectionUtils.isEmpty(userList)){ |
| | | throw new ValidationException("该微信已绑定其他账号"); |
| | | } |
| | | |
| | | UserWechat wechat = wechatMapper.selectOne(new LambdaQueryWrapper<UserWechat>() |
| | | .eq(UserWechat::getUserId,userId)); |
| | | if(wechat == null){ |
| | |
| | | wechat.setRealName(dto.getRealName()); |
| | | wechatMapper.updateById(wechat); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | public User getExistUserByOpenId(String openId, String sessionKey, String unionId, String userType) { |
| | | List<String> userTypes = new ArrayList<>(); |
| | | userTypes.add(userType); |
| | | User user = userMapper.getByOpenID(openId,userTypes); |
| | | return user; |
| | | List<User> userList = userMapper.getByOpenID(openId,userTypes); |
| | | if(!CollectionUtils.isEmpty(userList)){ |
| | | return userList.get(0); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public void registWxUser(CreateWechatUserDTO dto) { |