Commit 8bbea139 authored by 陈家荣's avatar 陈家荣

Merge branch 'development' of git.wxpai.cn:scrmgroup/pisns-forum-api into development

Conflicts:
	app/controllers/admin/forumThread.js
parents 3e3442e8 672e676a
...@@ -328,14 +328,12 @@ router.post('/thread/comment/update/:cid', function(req, res, next) { ...@@ -328,14 +328,12 @@ router.post('/thread/comment/update/:cid', function(req, res, next) {
// var commentList = result.comments; // var commentList = result.comments;
// result.comments = forumThreadService.remove(commentList, cid); // result.comments = forumThreadService.remove(commentList, cid);
var commentList = result.comments; // var commentList = result.comments;
var comments = forumThreadService.remove(commentList, cid); // var comments = forumThreadService.remove(commentList, cid);
forumThreadService.updateThreadById(tid, { forumThreadService.updateThreadById(tid, {
comments: comments, "$pull" : { "comments" : { "_id" : cid}},
$inc: { $inc: { comment_count: -1 }
comment_count: -1
}
}, function(err, result) { }, function(err, result) {
if (err) { if (err) {
console.error(err); console.error(err);
...@@ -365,7 +363,12 @@ router.post('/thread/comment/update/:cid', function(req, res, next) { ...@@ -365,7 +363,12 @@ router.post('/thread/comment/update/:cid', function(req, res, next) {
var commentList = result.comments; var commentList = result.comments;
var comments = forumCommentService.remove(commentList, cid); var comments = forumCommentService.remove(commentList, cid);
forumCommentService.updateCommentById(parent_cid, { forumCommentService.updateCommentById(parent_cid, {
comments: comments "$pull": {
"comments": {
"_id": cid
}
}
}, function(err, result) { }, function(err, result) {
if (err) { if (err) {
res.json(returnCode.BUSY); res.json(returnCode.BUSY);
...@@ -428,32 +431,48 @@ router.post('/thread/comment/update/:cid/comments', function(req, res, next) { ...@@ -428,32 +431,48 @@ router.post('/thread/comment/update/:cid/comments', function(req, res, next) {
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 cid = req.params.cid || null;
var replayComment_id = req.body.replayComment_id; 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) { // forumCommentService.getCommentById(cid, function(err, result) {
if (err) { // if (err) {
console.error(err); // console.error(err);
res.json(returnCode.BUSY); // res.json(returnCode.BUSY);
} else { // } else {
var commentList = result.comments; // // var commentList = result.comments;
result.comments.push(replayComment_id); // // result.comments.push(replayComment_id);
forumCommentService.updateCommentById(cid, { // forumCommentService.updateCommentById(cid, {
$push: { // $push: {
comments: replayComment_id // comments: replayComment_id
} // }
}, // },
function(err, result) { // function(err, result) {
if (err) { // if (err) {
console.error(err); // console.error(err);
res.json(returnCode.BUSY); // res.json(returnCode.BUSY);
} else { // } else {
res.json(returnCode.SUCCESS); // res.json(returnCode.SUCCESS);
} // }
}); // });
// }
// });
}
});
}); });
//添加评论 //添加评论
......
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