Commit 572d8481 authored by 张淼's avatar 张淼

1

parent 6bec50cc
......@@ -478,7 +478,7 @@ router.post('/thread/:tid/comment/:cid/create', function(req, res, next) {
level:'2'
};
//4.创建文章评论
forumCommentService.createComment(entity,function(err,result){
forumCommentService.createComment(entity,function(err,newComment){
if(err){
callback(err,null);
}else{
......@@ -487,12 +487,12 @@ router.post('/thread/:tid/comment/:cid/create', function(req, res, next) {
if(comments && comments.length>0){
array=comments;
}
array.push(result._id);
array.push(newComment._id);
forumCommentService.updateCommentById(cid,{comments:array},function(err,result){
if(err){
callback(err,null);
}else{
callback(null,null);
callback(null,newComment);
}
});
}
......@@ -513,7 +513,16 @@ router.post('/thread/:tid/comment/:cid/create', function(req, res, next) {
console.error(err);
res.json(returnCode.BUSY);
}else{
res.json(returnCode.SUCCESS);
ForumComment.populate(results[0], {path:'from to', select:'uid nickName icon comments'} , function(err, c){
if(err){
res.json(returnCode.BUSY);
}else{
var rs={};
rs.data=results[0];
res.json(_.assign(rs,returnCode.SUCCESS));
}
});
// res.json(returnCode.SUCCESS);
}
});
}
......@@ -574,10 +583,10 @@ router.post('/thread/:tid/comment/:cid/delete', function(req, res, next) {
});
//评论列表
router.post('/thread/:tid/comment/list', function(req, res, next) {
router.get('/thread/:tid/comment/list', function(req, res, next) {
var tid=req.params.tid || null;
var pageNo = req.query.pageNo || 1;
var pageSize = req.query.pageSize || 5;
var pageSize = req.query.pageSize || 10;
var conditions={
thread:tid,
......
......@@ -58,7 +58,7 @@ exports.getThreadById=function(tid,callback){
level:'1'
};
//获取最新5条评论
forumCommentService.getAllComment(conditions,1,5,function(err,results){
forumCommentService.getAllComment(conditions,1,10,function(err,results){
if(err){
console.log(err);
cb(err,null);
......@@ -207,7 +207,7 @@ exports.getAllThreadByFid= function(conditions,pageNo,pageSize,callback) {
var skip = (pageNo - 1) * pageSize;
var limit = count - skip > pageSize ? pageSize : (count - skip);
ForumThread.find(conditions).populate('from').populate('info').populate({path:'tag'}).populate({path:'comments',options:{limit:5,sort:'-created'}, select:'from to created content'}).limit(limit).skip(skip).sort('-top created').exec(function(err, docs) {
ForumThread.find(conditions).populate('from').populate('info').populate({path:'tag'}).populate({path:'comments',options:{limit:5,sort:'-created'}, select:'from to created content'}).limit(limit).skip(skip).sort('-top -created').exec(function(err, docs) {
if (err) {
console.error(err);
callback(err,null);
......
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