|
|
@@ -21,6 +21,7 @@ import io.jpress.model.Comment;
|
|
|
|
|
|
import java.math.BigInteger;
|
|
|
import java.util.LinkedList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
public class CommentQuery extends JBaseQuery {
|
|
|
|
|
|
@@ -65,6 +66,38 @@ public class CommentQuery extends JBaseQuery {
|
|
|
return DAO.paginate(pageNumber, pageSize, select, fromBuilder.toString(), params.toArray());
|
|
|
}
|
|
|
|
|
|
+ public Page<Comment> uuHelperPaginateWithContent(int pageNumber, int pageSize, String module, String type,
|
|
|
+ BigInteger contentId, BigInteger parentCommentId, String status) {
|
|
|
+
|
|
|
+ String select = " select DISTINCT c.id, c.*,content.title content_title,u.username,u.nickname,u.avatar, "
|
|
|
+ + "quote_comment.text qc_content,quote_comment.author qc_author,"
|
|
|
+ + "quote_user.username qc_username,quote_user.nickname qc_nickname,quote_user.avatar qc_avatar ";
|
|
|
+
|
|
|
+ StringBuilder fromBuilder = new StringBuilder(" from comment c");
|
|
|
+ fromBuilder.append(" left join content on c.content_id = content.id");
|
|
|
+ fromBuilder.append(" left join user u on c.user_id = u.id ");
|
|
|
+ fromBuilder.append(" left join comment quote_comment on c.id = quote_comment.parent_id");
|
|
|
+ fromBuilder.append(" left join user quote_user on quote_comment.user_id = quote_user.id ");
|
|
|
+
|
|
|
+ LinkedList<Object> params = new LinkedList<Object>();
|
|
|
+ boolean needWhere = true;
|
|
|
+ needWhere = appendIfNotEmpty(fromBuilder, " c.`type`", type, params, needWhere);
|
|
|
+ needWhere = appendIfNotEmpty(fromBuilder, " c.content_module", module, params, needWhere);
|
|
|
+ needWhere = appendIfNotEmpty(fromBuilder, " c.`status`", status, params, needWhere);
|
|
|
+ //needWhere = appendIfNotEmpty(fromBuilder, " c.parent_id", parentCommentId, params, needWhere);
|
|
|
+ needWhere = appendIfNotEmpty(fromBuilder, " content.id", contentId, params, needWhere);
|
|
|
+
|
|
|
+
|
|
|
+ //软文详情页评论排序,先按是否置顶排,再按点赞数排,最后按评论时间排。
|
|
|
+ fromBuilder.append("and c.parent_id is null ORDER BY c.order_number desc,c.vote_up desc, c.created desc");
|
|
|
+
|
|
|
+
|
|
|
+ if (params.isEmpty()) {
|
|
|
+ return DAO.paginate(pageNumber, pageSize, select, fromBuilder.toString());
|
|
|
+ }
|
|
|
+ return DAO.paginate(pageNumber, pageSize, select, fromBuilder.toString(), params.toArray());
|
|
|
+ }
|
|
|
+
|
|
|
public Page<Comment> paginateWithContentNotInDelete(int pageNumber, int pageSize, String module, String type,
|
|
|
BigInteger contentId, BigInteger parentCommentId) {
|
|
|
|
|
|
@@ -135,7 +168,7 @@ public class CommentQuery extends JBaseQuery {
|
|
|
}
|
|
|
|
|
|
public Page<Comment> uuHelperPaginateByContentId(int pageNumber, int pageSize, BigInteger contentId, String module) {
|
|
|
- return paginateWithContent(pageNumber, pageSize, module, null, contentId, null, Comment.STATUS_NORMAL);
|
|
|
+ return uuHelperPaginateWithContent(pageNumber, pageSize, module, null, contentId, null, Comment.STATUS_NORMAL);
|
|
|
}
|
|
|
|
|
|
public long findCountByContentIdInNormal(BigInteger contentId) {
|
|
|
@@ -221,4 +254,15 @@ public class CommentQuery extends JBaseQuery {
|
|
|
public long findCountByContentIdAndUuUserId(BigInteger contentId, BigInteger uuUserId) {
|
|
|
return DAO.doFindCount(" content_id = ? and uu_user_id=? ", contentId, uuUserId);
|
|
|
}
|
|
|
+
|
|
|
+ //只获取最新的一条回复
|
|
|
+ public Comment findLatestSon(BigInteger id) {
|
|
|
+ Comment comment = null;
|
|
|
+ List<Comment> list = DAO.find("SELECT * from jpress_comment where parent_id= " + id +" ORDER BY created desc LIMIT 1");
|
|
|
+ if (list.size() > 0) {
|
|
|
+ comment = list.get(0);
|
|
|
+ }
|
|
|
+ return comment;
|
|
|
+ }
|
|
|
+
|
|
|
}
|