Commit e0ece109 authored by 陈家荣's avatar 陈家荣

回复二级评论时,出现无楼层互动评论

parent 9579b9cb
......@@ -617,7 +617,6 @@ router.put('/recommend_threads/orderIDX/:id/:order', function(req, res, next) {
});
//评论列表
router.get('/thread/:tid/comment/list', function(req, res, next) {
var tid = req.params.tid || null;
var pageNo = req.query.pageNo || 1;
var pageSize = req.query.pageSize || 10;
......@@ -649,11 +648,21 @@ router.get('/thread/:tid/comment/list', function(req, res, next) {
if (e.level == 1) {
cb(null, e);
} else {
forumCommentService.getCommentParent(e._id, function(err, p_comment) {
if(p_comment){
forumCommentService.getCommentParent(new mongoose.Types.ObjectId(e._id), function(err, p_comment) {
if(p_comment && p_comment.floor){
var comment = e.toObject();
comment.floor = p_comment.floor;
cb(null, comment);
} else if(p_comment && !p_comment.floor){ //上一级没有楼层就再查上一级的评论
forumCommentService.getCommentParent(new mongoose.Types.ObjectId(p_comment._id), function(err, p_p_comment) {
if(p_comment){
var comment = e.toObject();
comment.floor = p_p_comment.floor;
cb(null, comment);
}else{
cb(null, e);
}
});
}else{
cb(null, e);
}
......@@ -921,16 +930,6 @@ router.post('/thread/comment/update/:cid/comments', function(req, res, next) {
var tid = req.body.tid || null;
var cid = req.params.cid || null;
var replayComment_id = req.body.replayComment_id;
// 获取评论的子评论列表
// 更新文章评论 + 1
// forumThreadService.updateThreadCommentCountInc(tid, function(err, thread) {
// if (err) {
// console.error(err);
// }
// });
// 更新评论对象
// result.comment_count+=1; // 回复评论+1
forumCommentService.updateCommentById(cid, {
$push: {
comments: replayComment_id
......@@ -949,53 +948,6 @@ router.post('/thread/comment/update/:cid/comments', function(req, res, next) {
});
});
// 更新评论的子评论列表
router.post('/thread/comment/update/:cid/comments', function(req, res, next) {
var cid = req.params.cid || null;
var replayComment_id = req.body.replayComment_id;
forumCommentService.updateCommentById(cid, {
$push: {
comments: replayComment_id
}
},
function(err, result) {
if (err) {
console.error(err);
res.json(returnCode.BUSY);
} else {
res.json(returnCode.SUCCESS);
}
});
// 获取评论的子评论列表
// forumCommentService.getCommentById(cid, function(err, result) {
// if (err) {
// console.error(err);
// res.json(returnCode.BUSY);
// } else {
// // var commentList = result.comments;
// // result.comments.push(replayComment_id);
// forumCommentService.updateCommentById(cid, {
// $push: {
// comments: replayComment_id
// }
// },
// function(err, result) {
// if (err) {
// console.error(err);
// res.json(returnCode.BUSY);
// } else {
// res.json(returnCode.SUCCESS);
// }
// });
// }
// });
});
//添加评论
router.post('/thread/comment/add', function(req, res, next) {
var tid = req.body.tid || null;
......@@ -1043,7 +995,6 @@ router.post('/thread/comment/add', function(req, res, next) {
});
}
}
entity.from = user;
callback();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment