Commit bc504856 authored by 陈志良's avatar 陈志良

1

parent f4858ecf
...@@ -616,19 +616,16 @@ router.post('/thread/:tid/comment/create', function(req, res, next) { ...@@ -616,19 +616,16 @@ router.post('/thread/:tid/comment/create', function(req, res, next) {
}); });
//新增文章评论 //新增文章评论
router.post('/thread/:tid/comment/createv2', function(req, res, next) { router.post('/thread/:tid/comment/createv2', function(req, res, next) {
console.log('------------------in------------------');
var userId = req.session.mobileForumUser.userId; var userId = req.session.mobileForumUser.userId;
var data = null;
forumLimitActionRefService.checkLimitActionProhibitionOfSpeech(userId, function(err, isProhibition){ forumLimitActionRefService.checkLimitActionProhibitionOfSpeech(userId, function(err, isProhibition){
console.log('1');
if(err){ if(err){
console.error(err); console.error(err);
res.json(returnCode.PROHIBITION_OF_SPEECH); res.json(returnCode.PROHIBITION_OF_SPEECH);
}else{ }else{
console.log('2');
if(isProhibition){ if(isProhibition){
res.json(returnCode.PROHIBITION_OF_SPEECH); res.json(returnCode.PROHIBITION_OF_SPEECH);
}else{ }else{
console.log('3');
var tid = req.params.tid || null; var tid = req.params.tid || null;
if (tid) { if (tid) {
var integral = req.session.openUser.integral || 0; var integral = req.session.openUser.integral || 0;
...@@ -680,6 +677,7 @@ router.post('/thread/:tid/comment/createv2', function(req, res, next) { ...@@ -680,6 +677,7 @@ router.post('/thread/:tid/comment/createv2', function(req, res, next) {
if (err) { if (err) {
callback(err, null); callback(err, null);
} else { } else {
data = newComment ;
var comments = thread.comments; var comments = thread.comments;
// console.log('========='); // console.log('=========');
// console.log(comments); // console.log(comments);
...@@ -732,43 +730,9 @@ router.post('/thread/:tid/comment/createv2', function(req, res, next) { ...@@ -732,43 +730,9 @@ router.post('/thread/:tid/comment/createv2', function(req, res, next) {
} }
} }
}); });
var rs = {};
async.parallel([ rs.data = data;
function(callback) { res.json(_.assign(rs, returnCode.SUCCESS));
//获取最新5条评论
var conditions = {
thread: tid,
level: '1'
};
forumCommentService.getAllComment(conditions, 1, 5, function(err, results) {
if (err) {
console.log(err);
callback(err, null);
} else {
callback(null, results);
}
});
},
function(callback) {
forumThreadService.getThreadById(tid, function(err, thread) {
if (err) {
console.log(err);
callback(err, null);
} else {
callback(null, thread);
}
});
}
], function(err, results) {
if (err) {
res.json(returnCode.BUSY);
} else {
var rs = {};
rs.comments = results[0].items;
rs.commentCount = results[1].comment_count;
res.json(_.assign(rs, 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