|
|
@@ -138,16 +138,16 @@ public class CommentQuery extends JBaseQuery {
|
|
|
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.parent_id = quote_comment.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 ");
|
|
|
|
|
|
fromBuilder.append(" WHERE c.status <> '" + Comment.STATUS_DELETE + "' ");
|
|
|
|
|
|
if (hasSon == true) {
|
|
|
- fromBuilder.append("and c.parent_id is not null ");
|
|
|
+ fromBuilder.append("and quote_comment.parent_id is not null ");
|
|
|
} else {
|
|
|
//不找作者本身的回复(需再思考 数量和实际显示)
|
|
|
- fromBuilder.append("and c.parent_id is null and c.user_id != content.user_id ");
|
|
|
+ fromBuilder.append("and c.parent_id is null and quote_comment.id is null and c.user_id != content.user_id ");
|
|
|
}
|
|
|
|
|
|
LinkedList<Object> params = new LinkedList<Object>();
|
|
|
@@ -228,9 +228,9 @@ public class CommentQuery extends JBaseQuery {
|
|
|
count = DAO.doFindCount("content_module = ? and parent_id is not null and content_id = ?", module ,contentId);
|
|
|
} else {
|
|
|
if (authorUserId == null) {
|
|
|
- count = DAO.doFindCount("content_module = ? and parent_id is null and content_id = ? ", module ,contentId);
|
|
|
+ count = DAO.doFindCount("id NOT IN (select c.parent_id from comment c where c.parent_id IS NOT null) and content_module = ? and parent_id is null and content_id = ? ", module ,contentId);
|
|
|
} else {
|
|
|
- count = DAO.doFindCount("content_module = ? and parent_id is null and content_id = ? and user_id != ?", module ,contentId ,authorUserId);
|
|
|
+ count = DAO.doFindCount("id NOT IN (select c.parent_id from comment c where c.parent_id IS NOT null) and content_module = ? and parent_id is null and content_id = ? and user_id != ?", module ,contentId ,authorUserId);
|
|
|
}
|
|
|
}
|
|
|
|