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,6 +439,20 @@ router.post('/thread/:tid/comment/create', function(req, res, next) { ...@@ -442,6 +439,20 @@ router.post('/thread/:tid/comment/create', function(req, res, next) {
level: '1', level: '1',
floor: floor floor: floor
}; };
var conditions = {
thread: thread._id,
level: '1'
};
forumCommentService.count(conditions, function(err, count) {
if (err) {
console.log(err);
callback(err, null);
} else {
// callback(null, count);
if(count){
entity.floor = count + 1;
}
//4.创建文章评论 //4.创建文章评论
forumCommentService.createComment(entity, function(err, newComment) { forumCommentService.createComment(entity, function(err, newComment) {
if (err) { if (err) {
...@@ -467,6 +478,8 @@ router.post('/thread/:tid/comment/create', function(req, res, next) { ...@@ -467,6 +478,8 @@ router.post('/thread/:tid/comment/create', function(req, res, next) {
}); });
} }
}); });
}
});
}, },
function(callback) { function(callback) {
//3.更新文章统计数据(评论数) //3.更新文章统计数据(评论数)
......
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