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

1

parent 3e747e2a
...@@ -14,7 +14,7 @@ var forumShareLogService = require('../../service/forumShareLogService'); ...@@ -14,7 +14,7 @@ var forumShareLogService = require('../../service/forumShareLogService');
var forumCommentService = require('../../service/forumCommentService'); var forumCommentService = require('../../service/forumCommentService');
var forumUserThreadControlService = require('../../service/forumUserThreadControlService'); var forumUserThreadControlService = require('../../service/forumUserThreadControlService');
var forumLimitActionRefService = require('../../service/forumLimitActionRefService'); var forumLimitActionRefService = require('../../service/forumLimitActionRefService');
var commentTips = require('../../utils/commentTips');
var httpService = require('../../service/httpService'); var httpService = require('../../service/httpService');
var user = require('../../utils/user'); var user = require('../../utils/user');
...@@ -505,8 +505,6 @@ router.post('/thread/:tid/comment/create', function(req, res, next) { ...@@ -505,8 +505,6 @@ router.post('/thread/:tid/comment/create', function(req, res, next) {
if (err) { if (err) {
callback(err, null); callback(err, null);
} else { } else {
//
commentTips.incrTips(req.session.user.ent_code,thread.from);
var comments = thread.comments; var comments = thread.comments;
// console.log('========='); // console.log('=========');
// console.log(comments); // console.log(comments);
...@@ -619,7 +617,6 @@ router.post('/thread/:tid/comment/create', function(req, res, next) { ...@@ -619,7 +617,6 @@ router.post('/thread/:tid/comment/create', function(req, res, next) {
//新增文章评论 //新增文章评论
router.post('/thread/:tid/comment/create/new', function(req, res, next) { router.post('/thread/:tid/comment/create/new', function(req, res, next) {
var userId = req.session.mobileForumUser.userId; var userId = req.session.mobileForumUser.userId;
var newCommentId = null;
forumLimitActionRefService.checkLimitActionProhibitionOfSpeech(userId, function(err, isProhibition){ forumLimitActionRefService.checkLimitActionProhibitionOfSpeech(userId, function(err, isProhibition){
if(err){ if(err){
console.error(err); console.error(err);
...@@ -678,8 +675,10 @@ router.post('/thread/:tid/comment/create/new', function(req, res, next) { ...@@ -678,8 +675,10 @@ router.post('/thread/:tid/comment/create/new', function(req, res, next) {
if (err) { if (err) {
callback(err, null); callback(err, null);
} else { } else {
newCommentId = newComment._id;
var comments = thread.comments; var comments = thread.comments;
// console.log('=========');
// console.log(comments);
// console.log('=========');
var array = []; var array = [];
if (comments && comments.items && comments.items.length > 0) { if (comments && comments.items && comments.items.length > 0) {
array = comments.items; array = comments.items;
...@@ -731,17 +730,17 @@ router.post('/thread/:tid/comment/create/new', function(req, res, next) { ...@@ -731,17 +730,17 @@ router.post('/thread/:tid/comment/create/new', function(req, res, next) {
async.parallel([ async.parallel([
function(callback) { function(callback) {
//获取创建评论 //获取最新5条评论
var conditions = { var conditions = {
thread: tid, thread: tid,
level: '1' level: '1'
}; };
forumCommentService.getPopulateCommentById(newCommentId, function(err, doc) { forumCommentService.getAllComment(conditions, 1, 5, function(err, results) {
if (err) { if (err) {
console.log(err); console.log(err);
callback(err, null); callback(err, null);
} else { } else {
callback(null, doc); callback(null, results);
} }
}); });
}, },
...@@ -760,9 +759,9 @@ router.post('/thread/:tid/comment/create/new', function(req, res, next) { ...@@ -760,9 +759,9 @@ router.post('/thread/:tid/comment/create/new', function(req, res, next) {
res.json(returnCode.BUSY); res.json(returnCode.BUSY);
} else { } else {
var rs = {}; var rs = {};
rs.data = results[0]; rs.comments = results[0].items;
var result = _.assign(rs, returnCode.SUCCESS); rs.commentCount = results[1].comment_count;
res.json(result); res.json(_.assign(rs, returnCode.SUCCESS));
} }
}); });
...@@ -834,7 +833,6 @@ router.post('/thread/:tid/comment/:cid/create', function(req, res, next) { ...@@ -834,7 +833,6 @@ router.post('/thread/:tid/comment/:cid/create', function(req, res, next) {
if (err) { if (err) {
callback(err, null); callback(err, null);
} else { } else {
commentTips.incrTips(req.session.user.ent_code,req.body.to);
var comments = comment.comments; var comments = comment.comments;
var array = []; var array = [];
if (comments && comments.length > 0) { if (comments && comments.length > 0) {
......
...@@ -251,7 +251,6 @@ exports.getThreadById = function(tid, callback) { ...@@ -251,7 +251,6 @@ exports.getThreadById = function(tid, callback) {
} }
}); });
}; };
//根据ID获取文章 //根据ID获取文章
exports.getThreadByIdNoLimit = function(tid, callback) { exports.getThreadByIdNoLimit = function(tid, callback) {
async.parallel([ async.parallel([
...@@ -636,7 +635,7 @@ function getAllThreadByFidHelp(conditions, pageNo, pageSize, sort, callback) { ...@@ -636,7 +635,7 @@ function getAllThreadByFidHelp(conditions, pageNo, pageSize, sort, callback) {
limit: 5, limit: 5,
sort: '-created' sort: '-created'
}, },
select: 'from to created content' select: 'from to created content level'
}).limit(limit).skip(skip).sort(sortBy).exec(function(err, docs) { }).limit(limit).skip(skip).sort(sortBy).exec(function(err, docs) {
if (err) { if (err) {
console.error(err); console.error(err);
......
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