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

1

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