Commit 1ac44206 authored by 邓军's avatar 邓军

1

parent 454540ef
......@@ -30,7 +30,9 @@ router.post('/thread/create', function(req, res, next) {
var rs = {};
req.body.ent_code = req.session.user.ent_code;
if(!req.body.share){
delete req.body.share;
}
var uid = req.session.user.id;
// var uid='12345';
if (req.body.pid) {
......@@ -81,7 +83,9 @@ router.post('/thread/create', function(req, res, next) {
}
});
}
}); } }
});
}
}
});
});
......@@ -113,9 +117,20 @@ router.get('/thread/:tid/get', function(req, res, next) {
if (err) {
res.json(returnCode.BUSY);
} else {
rs.data = results[0];
rs.tagList = results[1];
res.json(_.assign(rs, returnCode.SUCCESS));
if (results[0].pid) {
forumThreadService.getById(results[0].pid, function(err, parentThread) {
rs.data = results[0];
rs.tagList = results[1];
rs.parentThread = parentThread;
res.json(_.assign(rs, returnCode.SUCCESS));
});
} else {
rs.data = results[0];
rs.tagList = results[1];
res.json(_.assign(rs, returnCode.SUCCESS));
}
}
});
} else {
......@@ -229,7 +244,7 @@ router.get('/threads/list', function(req, res, next) {
conditions.level = 2;
}
if(content){
if (content) {
conditions.content = {
$regex: content,
$options: 'i'
......@@ -241,7 +256,15 @@ router.get('/threads/list', function(req, res, next) {
console.error(err);
res.json(returnCode.BUSY);
} else {
res.json(_.assign(results, returnCode.SUCCESS));
if (results.items[0].pid) {
forumThreadService.getById(results.items[0].pid, function(err, parentThread) {
res.json(_.assign({
parentThread: parentThread
}, results, returnCode.SUCCESS));
});
} else {
res.json(_.assign(results, returnCode.SUCCESS));
}
}
});
});
......@@ -372,7 +395,14 @@ router.post('/thread/comment/update/:cid/comments', function(req, res, next) {
});
// 更新评论对象
// result.comment_count+=1; // 回复评论+1
forumCommentService.updateCommentById(cid, {$push:{comments:replayComment_id},$inc:{comment_count:1}}, function(err, result) {
forumCommentService.updateCommentById(cid, {
$push: {
comments: replayComment_id
},
$inc: {
comment_count: 1
}
}, function(err, result) {
if (err) {
console.error(err);
res.json(returnCode.BUSY);
......@@ -480,7 +510,7 @@ router.post('/thread/comment/add', function(req, res, next) {
res.json(returnCode.WRONG_PARAM);
}
// 测试环境
// entity.from = '55015675868b65a028187c49';
......
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