| | |
| | | |
| | | @Override |
| | | public AccountResponse wxLogin(String code){ |
| | | // try { |
| | | try { |
| | | //获取微信敏感数据 |
| | | // WxMaJscode2SessionResult session = WxMiniConfig.wxCustomerService.getUserService().getSessionInfo(code); |
| | | // String openId = session.getOpenid(); |
| | | // if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isBlank(openId)) { |
| | | // throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"获取openid失败!请联系管理员"); |
| | | // } |
| | | String openId = code; |
| | | WxMaJscode2SessionResult session = WxMiniConfig.wxCustomerService.getUserService().getSessionInfo(code); |
| | | String openId = session.getOpenid(); |
| | | if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isBlank(openId)) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"获取openid失败!请联系管理员"); |
| | | } |
| | | Member member = memberMapper.selectOne(new QueryWrapper<Member>().eq("OPENID", openId)); |
| | | if (member == null) { |
| | | member = new Member(); |
| | |
| | | String token = JwtTokenUtil.generateToken(payLoad); |
| | | AccountResponse accountResponse = new AccountResponse(); |
| | | accountResponse.setToken(token); |
| | | // accountResponse.setSessionKey(session.getSessionKey()); |
| | | accountResponse.setSessionKey(session.getSessionKey()); |
| | | accountResponse.setMember(member); |
| | | return accountResponse; |
| | | // } catch (WxErrorException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"微信登录异常!请联系管理员"); |
| | | } catch (WxErrorException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"微信登录异常!请联系管理员"); |
| | | } |
| | | |
| | | @Override |