@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 void editUserBasic(
      Long userId,
      String nickName,
      String userName,
      Integer sex,
      int birthdayYear,
      int birthdayMonth,
      int birthdayDay,
      String summary,
      String qqId,
      String wangwangId) {
    // 数据不能为空
    if (userId <= 0 || nickName.trim().equals("") || userName.trim().equals("")) {
      throw new IllegalArgumentException();
    }
    // 验证昵称格式
    if (!StringUtil.match(nickName, "^.{1,12}$")) {
      throw new ServiceException(ErrService.UserS.ACC_106, "昵称:“" + nickName + "”格式错误。");
    }
    // 验证生日格式
    Calendar calendar = Calendar.getInstance();
    try {
      calendar.set(birthdayYear, birthdayMonth - 1, birthdayDay);
    } catch (Exception e) {
      throw new ServiceException(
          ErrService.UserS.ACC_104,
          "生日:“" + birthdayYear + "年" + birthdayMonth + "月" + birthdayDay + "日”,格式错误。",
          e);
    }
    // 验证昵称
    User user = userDao.queryById(userId);
    if (!user.getNickName().equals(nickName)) {
      if (this.verifyNickRep(nickName)) {
        throw new ServiceException(ErrService.UserS.ACC_102, "昵称:“" + nickName + "”已经被使用。");
      }
    }

    JSONObject eaddress = new JSONObject();
    if (!StringUtil.isEmptyOrNull(qqId)) {
      eaddress.put("qqId", qqId);
    }
    if (!StringUtil.isEmptyOrNull(wangwangId)) {
      eaddress.put("wangwangId", wangwangId);
    }

    userDao.update(
        userId,
        nickName,
        userName,
        sex,
        birthdayYear,
        birthdayMonth,
        birthdayDay,
        eaddress.toString(),
        summary);
  }