Example #1
0
 public static String merge(
     String s,
     String k1,
     Object v1,
     String k2,
     Object v2,
     String k3,
     Object v3,
     String k4,
     Object v4) {
   return merge(s, CollectionUtils2.<String, Object>of(k1, v1, k2, v2, k3, v3, k4, v4));
 }
  @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);
  }
  @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));
  }
Example #4
0
 public static String merge(String s, Object[][] args) {
   return merge(s, CollectionUtils2.arraysToMap(args));
 }
Example #5
0
 public static String merge(String s, String k1, Object v1, String k2, Object v2) {
   return merge(s, CollectionUtils2.<String, Object>of(k1, v1, k2, v2));
 }