コード例 #1
0
 public static boolean isNameLeagal(String groupname) {
   List<AVObject> avObjects;
   AVQuery<AVObject> singlequery = new AVQuery<AVObject>("UserInfo");
   AVQuery<AVObject> groupquery = new AVQuery<AVObject>("Group");
   singlequery.whereEqualTo("username", groupname);
   try {
     avObjects = singlequery.find();
     if (avObjects.size() != 0) {
       return false;
     }
   } catch (AVException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   groupquery.whereEqualTo("groupname", groupname);
   try {
     avObjects = groupquery.find();
     if (avObjects.size() != 0) {
       return false;
     }
   } catch (AVException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return true;
 }
コード例 #2
0
 /**
  * 同步地从云端获得辅食信息
  *
  * @param page 页码
  * @param per 每页显示数
  * @return 辅食列表
  */
 public List<Supplement> findSuppsFromCloud(final int page, final int per) {
   query.orderByAscending(FIND_SORT);
   query.whereNotEqualTo("isDel", true);
   query.setSkip(page * per);
   try {
     return query.find();
   } catch (AVException e) {
     e.printStackTrace();
     return null;
   }
 }
コード例 #3
0
 private UpdateInfo getNewestUpdateInfo() throws AVException {
   AVQuery<UpdateInfo> query = AVObject.getQuery(UpdateInfo.class);
   query.setLimit(1);
   query.orderByDescending(UpdateInfo.VERSION);
   if (policy != null) {
     query.setCachePolicy(policy);
   }
   List<UpdateInfo> updateInfos = query.find();
   if (updateInfos.size() > 0) {
     return updateInfos.get(0);
   }
   return null;
 }
コード例 #4
0
 public static List<AVUser> searchUser(String searchName, int skip) throws AVException {
   AVQuery<AVUser> q = AVUser.getQuery(AVUser.class);
   q.whereContains(User.USERNAME, searchName);
   q.limit(Constant.PAGE_SIZE);
   q.skip(skip);
   AVUser user = AVUser.getCurrentUser();
   List<String> friendIds = new ArrayList<String>(CacheService.getFriendIds());
   friendIds.add(user.getObjectId());
   q.whereNotContainedIn(Constant.OBJECT_ID, friendIds);
   q.orderByDescending(Constant.UPDATED_AT);
   q.setCachePolicy(AVQuery.CachePolicy.NETWORK_ELSE_CACHE);
   List<AVUser> users = q.find();
   CacheService.registerUsers(users);
   return users;
 }
コード例 #5
0
  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;
  }