|
|
@@ -65,6 +65,13 @@ public class ContentQuery extends JBaseQuery {
|
|
|
return paginate(page, pagesize, modules, keyword, status, tids, null, month, null);
|
|
|
}
|
|
|
|
|
|
+ public Page<Content> uuHelperPaginateBySearch(int page, int pagesize, String module, String keyword,
|
|
|
+ String pushTime, String author, String copyRight, String taxonomy,
|
|
|
+ String status, BigInteger[] tids, String month) {
|
|
|
+ String[] modules = StringUtils.isNotBlank(module) ? new String[] { module } : null;
|
|
|
+ return uuHelperPaginate(page, pagesize, modules, keyword, pushTime, author, copyRight, taxonomy, status, tids, null, month, null);
|
|
|
+ }
|
|
|
+
|
|
|
public Page<Content> paginateByModuleInNormal(int page, int pagesize, String module) {
|
|
|
return paginate(page, pagesize, module, null, Content.STATUS_NORMAL, null, null, null);
|
|
|
}
|
|
|
@@ -107,6 +114,62 @@ public class ContentQuery extends JBaseQuery {
|
|
|
return DAO.paginate(page, pagesize, true, select, sql.toString(), params.toArray());
|
|
|
}
|
|
|
|
|
|
+ public Page<Content> uuHelperPaginateByModuleNotInDelete(int page, int pagesize, String module, String keyword,
|
|
|
+ String pushTime, String author, String copyRight, String taxonomy,
|
|
|
+ BigInteger[] taxonomyIds, String month) {
|
|
|
+
|
|
|
+ StringBuilder sql = new StringBuilder(" from content c");
|
|
|
+ sql.append(" left join mapping m on c.id = m.`content_id`");
|
|
|
+ sql.append(" left join taxonomy t on m.`taxonomy_id` = t.id");
|
|
|
+ sql.append(" left join metadata d on c.id = d.`object_id`");
|
|
|
+ sql.append(" left join metadata d1 on c.id = d1.`object_id`");
|
|
|
+ sql.append(" where c.status <> ?");
|
|
|
+
|
|
|
+ LinkedList<Object> params = new LinkedList<Object>();
|
|
|
+ params.add(Content.STATUS_DELETE);
|
|
|
+
|
|
|
+ appendIfNotEmpty(sql, "c.module", module, params, false);
|
|
|
+ //uuhelper过滤筛选
|
|
|
+ if (StringUtils.isNotBlank(pushTime)) {
|
|
|
+ appendIfNotEmpty(sql, "d.meta_key", "push_time", params, false);
|
|
|
+ appendIfNotEmpty(sql, "d.meta_value", pushTime, params, false);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(copyRight)) {
|
|
|
+ appendIfNotEmpty(sql, "d1.meta_key", "copy_right", params, false);
|
|
|
+ appendIfNotEmpty(sql, "d1.meta_value", copyRight, params, false);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(author)) {
|
|
|
+ appendIfNotEmpty(sql, "c.author", author, params, false);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(taxonomy)) {
|
|
|
+ appendIfNotEmpty(sql, "t.title", taxonomy, params, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(keyword)) {
|
|
|
+ sql.append(" AND c.title like ? ");
|
|
|
+ params.add("%" + keyword + "%");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (taxonomyIds != null && taxonomyIds.length > 0) {
|
|
|
+ sql.append(" AND t.id in " + toString(taxonomyIds));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(month)) {
|
|
|
+ sql.append(" DATE_FORMAT( c.created, \"%Y-%m\" ) = ?");
|
|
|
+ params.add(month);
|
|
|
+ }
|
|
|
+
|
|
|
+ sql.append(" group by c.id");
|
|
|
+ sql.append(" ORDER BY c.created DESC");
|
|
|
+
|
|
|
+ String select = "select c.*";
|
|
|
+ if (params.isEmpty()) {
|
|
|
+ return DAO.paginate(page, pagesize, true, select, sql.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ return DAO.paginate(page, pagesize, true, select, sql.toString(), params.toArray());
|
|
|
+ }
|
|
|
+
|
|
|
public Page<Content> paginateInNormal(int page, int pagesize, String module, BigInteger[] taxonomyIds,
|
|
|
String orderBy) {
|
|
|
|
|
|
@@ -244,6 +307,88 @@ public class ContentQuery extends JBaseQuery {
|
|
|
return DAO.paginate(page, pagesize, true, select, sql.toString(), params.toArray());
|
|
|
}
|
|
|
|
|
|
+ public Page<Content> uuHelperPaginate(int page, int pagesize, String[] modules, String keyword,
|
|
|
+ String pushTime, String author, String copyRight, String taxonomy,
|
|
|
+ String status, BigInteger[] taxonomyIds, BigInteger userId, String month, String orderBy) {
|
|
|
+
|
|
|
+ String[] texts = null;
|
|
|
+ // 关键词处理
|
|
|
+ if (keyword != null) {
|
|
|
+ texts = keyword.split(" ");
|
|
|
+ }
|
|
|
+
|
|
|
+ String select = "select c.*";
|
|
|
+
|
|
|
+ StringBuilder sql = new StringBuilder(" from content c");
|
|
|
+ sql.append(" left join mapping m on c.id = m.`content_id`");
|
|
|
+ sql.append(" left join taxonomy t on m.`taxonomy_id` = t.id");
|
|
|
+
|
|
|
+ //连接元数据表
|
|
|
+ sql.append(" left join metadata d on c.id = d.`object_id`");
|
|
|
+ //uuhelper元数据过滤时用
|
|
|
+ sql.append(" left join metadata d1 on c.id = d1.`object_id`");
|
|
|
+
|
|
|
+ LinkedList<Object> params = new LinkedList<Object>();
|
|
|
+
|
|
|
+ boolean needWhere = true;
|
|
|
+ needWhere = appendIfNotEmpty(sql, "c.module", modules, params, needWhere);
|
|
|
+ needWhere = appendIfNotEmpty(sql, "c.status", status, params, needWhere);
|
|
|
+ needWhere = appendIfNotEmpty(sql, "c.user_id", userId, params, needWhere);
|
|
|
+
|
|
|
+ //uuhelper过滤筛选
|
|
|
+ if (StringUtils.isNotBlank(pushTime)) {
|
|
|
+ needWhere = appendIfNotEmpty(sql, "d.meta_key", "push_time", params, needWhere);
|
|
|
+ needWhere = appendIfNotEmpty(sql, "d.meta_value", pushTime, params, needWhere);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(copyRight)) {
|
|
|
+ needWhere = appendIfNotEmpty(sql, "d1.meta_key", "copy_right", params, needWhere);
|
|
|
+ needWhere = appendIfNotEmpty(sql, "d1.meta_value", copyRight, params, needWhere);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(author)) {
|
|
|
+ needWhere = appendIfNotEmpty(sql, "c.author", author, params, needWhere);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(taxonomy)) {
|
|
|
+ needWhere = appendIfNotEmpty(sql, "t.title", taxonomy, params, needWhere);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 比对
|
|
|
+ if (null != texts) {
|
|
|
+ for (String key : texts) {
|
|
|
+ if (StringUtils.isNotBlank(key)) {
|
|
|
+ needWhere = appendWhereOrAnd(sql, needWhere);
|
|
|
+ sql.append(" (c.title like ? ");
|
|
|
+ params.add("%" + key + "%");
|
|
|
+ sql.append(" or c.text like ? ");
|
|
|
+ params.add("%" + key + "%");
|
|
|
+ sql.append(" or c.summary like ? )");
|
|
|
+ params.add("%" + key + "%");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sql.append(" and c.text is not null ");
|
|
|
+
|
|
|
+ if (taxonomyIds != null && taxonomyIds.length > 0) {
|
|
|
+ needWhere = appendWhereOrAnd(sql, needWhere);
|
|
|
+ sql.append(" t.id in " + toString(taxonomyIds));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(month)) {
|
|
|
+ needWhere = appendWhereOrAnd(sql, needWhere);
|
|
|
+ sql.append(" DATE_FORMAT( c.created, \"%Y-%m\" ) = ?");
|
|
|
+ params.add(month);
|
|
|
+ }
|
|
|
+
|
|
|
+ sql.append(" group by c.id");
|
|
|
+
|
|
|
+ buildOrderBy(orderBy, sql);
|
|
|
+
|
|
|
+ if (params.isEmpty()) {
|
|
|
+ return DAO.paginate(page, pagesize, true, select, sql.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ return DAO.paginate(page, pagesize, true, select, sql.toString(), params.toArray());
|
|
|
+ }
|
|
|
+
|
|
|
protected String toString(Object[] a) {
|
|
|
int iMax = a.length - 1;
|
|
|
StringBuilder b = new StringBuilder();
|