@Override
  public String getRongToken(long userId, boolean isNew, String resAccountUri) {
    User user = this.getUserById(userId);
    if (user == null) {
      return null;
    }
    if (user.getRongToken() != null && !isNew) {
      return user.getRongToken();
    }

    String imgUrl = user.getPhotoPath();
    if (imgUrl != null && !imgUrl.startsWith("http://")) {
      imgUrl = resAccountUri + imgUrl;
    }

    UserToken ut = null;
    try {
      String appKey = "0vnjpoadnxp5z";
      String appSecret = "3UH04WirdR69D";
      ApiRongIM.init(appKey, appSecret);
      ut = ApiRongIM.getToken(user.getUserId() + "", user.getNickName(), imgUrl);
      user.setRongToken(ut.getToken());
    } catch (Exception e) {
      logger.error("userId=" + user.getUserId(), e);
    }
    // 修改数据库
    userDao.updateRongToken(userId, user.getRongToken());

    return user.getRongToken();
  }
  @Override
  public BindSite checkLogin(
      BindSite.SiteMark siteMark, String openId, String accessToken, long tokenExpireIn) {
    // 第三方用户信息在当前平台保存的信息
    BindSite bs = bindSiteDao.queryByOpenId(siteMark, openId);
    // 获取第三方用户信息
    BindSite bsOther = UserServiceImpl.getBindSite(siteMark, openId, accessToken);

    if (bs != null) {
      // 更新token等信息
      bsOther.setBindSiteId(bs.getBindSiteId());
      this.changeToken(bsOther, tokenExpireIn);
    } else {
      // 注册用户
      User user = register(bsOther.getNickName(), bsOther.getPhotoPath());
      // 绑定平台
      bs = bindSiteUser(user.getUserId(), siteMark, openId, accessToken, tokenExpireIn, true);
    }
    return bs;
  }