Commit 1489d5fb authored by 陈家荣's avatar 陈家荣

11

parent 94919241
...@@ -430,9 +430,6 @@ router.post('/thread/:tid/comment/create', function(req, res, next) { ...@@ -430,9 +430,6 @@ router.post('/thread/:tid/comment/create', function(req, res, next) {
async.parallel([ async.parallel([
function(callback) { function(callback) {
var floor = 1; var floor = 1;
if(thread.comments.items){
floor = thread.comments.items.length + 1;
}
var entity = { var entity = {
ent_code: req.session.user.ent_code, ent_code: req.session.user.ent_code,
from: user.getMobileUser(req), from: user.getMobileUser(req),
...@@ -442,27 +439,43 @@ router.post('/thread/:tid/comment/create', function(req, res, next) { ...@@ -442,27 +439,43 @@ router.post('/thread/:tid/comment/create', function(req, res, next) {
level: '1', level: '1',
floor: floor floor: floor
}; };
//4.创建文章评论
forumCommentService.createComment(entity, function(err, newComment) { var conditions = {
thread: thread._id,
level: '1'
};
forumCommentService.count(conditions, function(err, count) {
if (err) { if (err) {
console.log(err);
callback(err, null); callback(err, null);
} else { } else {
var comments = thread.comments; // callback(null, count);
// console.log('========='); if(count){
// console.log(comments); entity.floor = count + 1;
// console.log('=========');
var array = [];
if (comments && comments.items && comments.items.length > 0) {
array = comments.items;
} }
array.push(newComment._id); //4.创建文章评论
forumThreadService.updateThreadById(tid, { forumCommentService.createComment(entity, function(err, newComment) {
comments: array
}, function(err, result) {
if (err) { if (err) {
callback(err, null); callback(err, null);
} else { } else {
callback(null, null); var comments = thread.comments;
// console.log('=========');
// console.log(comments);
// console.log('=========');
var array = [];
if (comments && comments.items && comments.items.length > 0) {
array = comments.items;
}
array.push(newComment._id);
forumThreadService.updateThreadById(tid, {
comments: array
}, function(err, result) {
if (err) {
callback(err, null);
} else {
callback(null, null);
}
});
} }
}); });
} }
......
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