private void addQueryRule(T anchor, boolean afterwards, int pageSize, AVQuery<T> query) {

    // set page size
    query.limit(pageSize);
    // before or after

    String queryOrder = query.getOrder();
    if ((anchor != null) && (queryOrder != null)) {
      boolean isDescending = queryOrder.startsWith("-");
      String field = isDescending ? queryOrder.substring(1) : queryOrder;
      if ((isDescending && afterwards) || (!isDescending && !afterwards)) {
        query.whereLessThan(field, anchor.get(field));
      } else {
        query.whereGreaterThan(field, anchor.get(field));
      }
    }
  }
  public static List<CompanyPost> findCompanyPost(
      int skip, int limit, String dateString, String cityName) throws AVException {

    AVQuery<CompanyPost> q = CompanyPost.getQuery(CompanyPost.class);
    // hehe 还好哟示例
    // TODO  这里如果include user 其他用户没法发布评论啊....尼玛啊  但是为什么能取到ObjectId呢啊啊啊啊,ffff  这里查到了是不是要保存到cache里边啊?!
    q.include(CompanyPost.USER);
    q.include(CompanyPost.COMMENT);
    if (dateString != null && !dateString.isEmpty()) {
      Date startDate;
      Date endDate;
      Date nowDate = new Date();
      try {
        startDate = DateUtils.getFirstDayOfMonth(dateString, "yyyy-MM-dd");
        // 必须比今天要早不是么...
        if (nowDate.getTime() > startDate.getTime()) {
          startDate = nowDate;
        }
        endDate = DateUtils.getLastDayOfMonth(dateString, "yyyy-MM-dd");
      } catch (Exception e) {
        e.printStackTrace();
        return new ArrayList<>();
      }
      q.whereGreaterThan("datePlanned", startDate);
      q.whereLessThan("datePlanned", endDate);
    }

    if (cityName != null && !cityName.isEmpty()) {
      q.whereEqualTo("destination", cityName);
    }
    q.skip(skip);
    q.limit(limit);
    q.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE);
    q.orderByDescending(AVObject.CREATED_AT);
    List<CompanyPost> posts = q.find();
    for (int i = 0; i < posts.size(); i++) {
      CacheService.registerUser((LeanchatUser) posts.get(i).getPublisher());
    }
    return posts;
  }