Exemplo n.º 1
0
  @TraceCall
  @Override
  public RecordSet searchPages(Context ctx, String kw, int page, int count) {
    String skw = "%" + ObjectUtils.toString(kw) + "%";

    String sql =
        new SQLBuilder.Select()
            .select("page_id")
            .from(pageTable)
            .where(
                "destroyed_time=0 AND (name LIKE ${v(kw)} OR name_en LIKE ${v(kw)}) OR address LIKE ${v(kw)} OR address_en LIKE ${v(kw)}",
                "kw",
                skw)
            .page(page, count)
            .toString();

    SQLExecutor se = getSqlExecutor();
    RecordSet pageIdRecs = se.executeRecordSet(sql, null);
    long[] pageIds = CollectionUtils2.toLongArray(pageIdRecs.getIntColumnValues("page_id"));
    return getPages(ctx, pageIds);
  }
Exemplo n.º 2
0
  @TraceCall
  @Override
  public RecordSet getPagesForMe(Context ctx) {
    long viewerId = ctx.getViewerId();
    if (viewerId <= 0) return new RecordSet();

    final LinkedHashSet<Long> pageIds = new LinkedHashSet<Long>();

    String sql =
        new SQLBuilder.Select()
            .select("page_id")
            .from(pageTable)
            .where("destroyed_time=0 AND creator=${v(viewer_id)}", "viewer_id", viewerId)
            .toString();
    SQLExecutor se = getSqlExecutor();
    se.executeRecordHandler(
        sql,
        new RecordHandler() {
          @Override
          public void handle(Record rec) {
            pageIds.add(rec.getInt("page_id"));
          }
        });

    //        RecordSet groupRecs = GlobalLogics.getGroup().getGroups(ctx, Constants.GROUP_ID_BEGIN,
    // Constants.GROUP_ID_END, ctx.getViewerIdString(), "", "page_id", false);
    //        for (Record groupRec : groupRecs) {
    //            long pageId = groupRec.getInt("page_id", 0L);
    //            if (pageId > 0)
    //                pageIds.add(pageId);
    //        }

    long[] followedPageIds =
        GlobalLogics.getFriendship().getFollowedPageIds(ctx, ctx.getViewerId());
    if (ArrayUtils.isNotEmpty(followedPageIds)) {
      for (long pageId : followedPageIds) pageIds.add(pageId);
    }

    return getPages(ctx, CollectionUtils2.toLongArray(pageIds));
  }