String code = userLoginDTO.getCode();
log.info("{}",code);
String openid = getOpenid(code);
//判断当前的openid是否为空,如果为空表示登录失败
if(openid == null){
throw new LoginFailedException(MessageConstant.LOGIN_FAILED);
}
//判断当前用户是否为新用户
User userByOpenid = userMapper.getByOpenid(openid);
//如果是新用户则,自动完成注册
if (userByOpenid == null){
userByOpenid = User.builder().openid(openid).createTime(LocalDateTime.now())
.build();
userMapper.insert(userByOpenid);
}
//返回这个用户对象
return userByOpenid;

确认是否过期或者已经被二次使用过还有是不是A小程序的code,B小程序去使用