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

1

parent 454540ef
...@@ -30,7 +30,9 @@ router.post('/thread/create', function(req, res, next) { ...@@ -30,7 +30,9 @@ router.post('/thread/create', function(req, res, next) {
var rs = {}; var rs = {};
req.body.ent_code = req.session.user.ent_code; 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 = req.session.user.id;
// var uid='12345'; // var uid='12345';
if (req.body.pid) { if (req.body.pid) {
...@@ -81,7 +83,9 @@ router.post('/thread/create', function(req, res, next) { ...@@ -81,7 +83,9 @@ router.post('/thread/create', function(req, res, next) {
} }
}); });
} }
}); } } });
}
}
}); });
}); });
...@@ -113,10 +117,21 @@ router.get('/thread/:tid/get', function(req, res, next) { ...@@ -113,10 +117,21 @@ router.get('/thread/:tid/get', function(req, res, next) {
if (err) { if (err) {
res.json(returnCode.BUSY); res.json(returnCode.BUSY);
} else { } else {
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.data = results[0];
rs.tagList = results[1]; rs.tagList = results[1];
res.json(_.assign(rs, returnCode.SUCCESS)); res.json(_.assign(rs, returnCode.SUCCESS));
} }
}
}); });
} else { } else {
res.json(returnCode.WRONG_PARAM); res.json(returnCode.WRONG_PARAM);
...@@ -229,7 +244,7 @@ router.get('/threads/list', function(req, res, next) { ...@@ -229,7 +244,7 @@ router.get('/threads/list', function(req, res, next) {
conditions.level = 2; conditions.level = 2;
} }
if(content){ if (content) {
conditions.content = { conditions.content = {
$regex: content, $regex: content,
$options: 'i' $options: 'i'
...@@ -240,9 +255,17 @@ router.get('/threads/list', function(req, res, next) { ...@@ -240,9 +255,17 @@ router.get('/threads/list', function(req, res, next) {
if (err) { if (err) {
console.error(err); console.error(err);
res.json(returnCode.BUSY); res.json(returnCode.BUSY);
} else {
if (results.items[0].pid) {
forumThreadService.getById(results.items[0].pid, function(err, parentThread) {
res.json(_.assign({
parentThread: parentThread
}, results, returnCode.SUCCESS));
});
} else { } else {
res.json(_.assign(results, returnCode.SUCCESS)); res.json(_.assign(results, returnCode.SUCCESS));
} }
}
}); });
}); });
...@@ -372,7 +395,14 @@ router.post('/thread/comment/update/:cid/comments', function(req, res, next) { ...@@ -372,7 +395,14 @@ router.post('/thread/comment/update/:cid/comments', function(req, res, next) {
}); });
// 更新评论对象 // 更新评论对象
// result.comment_count+=1; // 回复评论+1 // 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) { if (err) {
console.error(err); console.error(err);
res.json(returnCode.BUSY); res.json(returnCode.BUSY);
......
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