Commit 7ae9df80 authored by 陈家荣's avatar 陈家荣

更新评论

parent b297a896
...@@ -923,8 +923,17 @@ router.post('/thread/comment/update/:cid', function(req, res, next) { ...@@ -923,8 +923,17 @@ router.post('/thread/comment/update/:cid', 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 tid = req.body.tid || null; var tid = req.body.tid || null;
var cid = req.params.cid || null; var cid = req.params.cid || null;
var floor = req.body.floor || null;
var replayComment_id = req.body.replayComment_id; var replayComment_id = req.body.replayComment_id;
forumCommentService.updateCommentById(cid, { var ent_code = req.session.user.ent_code;
var conditions = {
"thread": tid,
"level" : "1",
"floor" : floor,
"ent_code" : ent_code
};
forumCommentService.updateComment(conditions, {
$push: { $push: {
comments: replayComment_id comments: replayComment_id
}, },
...@@ -1013,7 +1022,7 @@ router.post('/thread/comment/add', function(req, res, next) { ...@@ -1013,7 +1022,7 @@ router.post('/thread/comment/add', function(req, res, next) {
forumCommentService.createComment(entity, function(err, comment) { forumCommentService.createComment(entity, function(err, comment) {
if (err) { if (err) {
callback(err); callback(err);
} else { } else if(entity.level == 1){
forumThreadService.getById(tid, function(err, thread) { forumThreadService.getById(tid, function(err, thread) {
if (entity.level == 1) { if (entity.level == 1) {
forumAboutMEService.saveCommentLevel1(thread, comment); forumAboutMEService.saveCommentLevel1(thread, comment);
...@@ -1038,6 +1047,13 @@ router.post('/thread/comment/add', function(req, res, next) { ...@@ -1038,6 +1047,13 @@ router.post('/thread/comment/add', function(req, res, next) {
callback(null, returnData); callback(null, returnData);
}); });
}); });
}else{
var returnData = {
comment: comment,
errorcode: 0,
errormsg: '请求成功'
}
callback(null, returnData);
} }
}); });
} }
......
...@@ -88,6 +88,13 @@ exports.updateCommentById = function(cid, entity, callback) { ...@@ -88,6 +88,13 @@ exports.updateCommentById = function(cid, entity, callback) {
}); });
}; };
//根据条件更新评论 entity
exports.updateComment = function(conditions, entity, callback) {
ForumComment.findOneAndUpdate(conditions, entity, function(err, doc) {
callback(err, doc);
});
};
//根据ID删除评论 //根据ID删除评论
exports.deleteCommentById = function(cid, callback) { exports.deleteCommentById = function(cid, 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