Commit 138ea52e authored by 陈志良's avatar 陈志良

1

parent 06980bc0
...@@ -268,7 +268,8 @@ router.get('/threads/list', function(req, res, next) { ...@@ -268,7 +268,8 @@ router.get('/threads/list', function(req, res, next) {
var status = req.query.status; var status = req.query.status;
var conditions = { var conditions = {
ent_code: req.session.user.ent_code, ent_code: req.session.user.ent_code,
level: 1 level: 1,
status:{$ne:3}
}; };
if (infoId) { if (infoId) {
conditions.info = infoId; conditions.info = infoId;
...@@ -674,100 +675,101 @@ var getClientIP = function(req) { ...@@ -674,100 +675,101 @@ var getClientIP = function(req) {
//给以前的已一级评论添加楼层 //给以前的已一级评论添加楼层
router.get('/thread/updateConmentFloor', function(req, res, next) { // router.get('/thread/updateConmentFloor', function(req, res, next) {
res.json(returnCode.SUCCESS); // res.json(returnCode.SUCCESS);
var conditions = { // var conditions = {
// ent_code: ent_code // // ent_code: ent_code
}; // };
async.waterfall([ // async.waterfall([
function(callback) { // 查找文章的总数 // function(callback) { // 查找文章的总数
forumThreadService.getAllCountByFid(conditions,function(err, count){ // forumThreadService.getAllCountByFid(conditions,function(err, count){
if(err){ // if(err){
callback(err, null); // callback(err, null);
}else{ // }else{
callback(null, count); // callback(null, count);
} // }
}); // });
}, // },
function(count, callback) { //查找所有文章 // function(count, callback) { //查找所有文章
forumThreadService.getAllThreadByFidNoLimit(conditions, 1, count, null, function(err, datas){ // forumThreadService.getAllThreadByFidNoLimit(conditions, 1, count, null, function(err, datas){
if(err){ // if(err){
callback(err, null); // callback(err, null);
}else{ // }else{
callback(null, datas); // callback(null, datas);
} // }
}); // });
} // }
], function (err, result) { // ], function (err, result) {
var asyncTasks = []; // var asyncTasks = [];
result.items.forEach(function(doc, t) { //遍历文章 // result.items.forEach(function(doc, t) { //遍历文章
asyncTasks.push(function(callback2) { // asyncTasks.push(function(callback2) {
//获取文章所有一级评论 // //获取文章所有一级评论
var conditions = { // var conditions = {
thread: doc._id, // thread: doc._id,
level: '1' // level: '1'
}; // };
async.waterfall([ // async.waterfall([
function(callback) { // function(callback) {
//统计评论数 // //统计评论数
forumCommentService.count(conditions, function(err, count) { // forumCommentService.count(conditions, function(err, count) {
if (err) { // if (err) {
console.log(err); // console.log(err);
callback(err, null); // callback(err, null);
} else { // } else {
callback(null, count); // callback(null, count);
} // }
}); // });
}, // },
function(count, callback) { // function(count, callback) {
//获取所有评论 // //获取所有评论
forumCommentService.getAllComment(conditions, 1, count, function(err, results) { // forumCommentService.getAllComment(conditions, 1, count, function(err, results) {
if (err) { // if (err) {
console.log(err); // console.log(err);
callback(err, null); // callback(err, null);
} else { // } else {
callback(null, results.items); // callback(null, results.items);
} // }
}); // });
}, // },
function(comments, callback) { // function(comments, callback) {
comments = _.sortBy(comments, function(comment){ // comments = _.sortBy(comments, function(comment){
return comment.created; // return comment.created;
}); // });
if(comments.length > 0){ // if(comments.length > 0){
// 给每一个评论添加楼层 // // 给每一个评论添加楼层
comments.forEach(function(comment,i){ // comments.forEach(function(comment,i){
forumCommentService.updateCommentFloorById(comment._id, i + 1, function(err,docc){ // forumCommentService.updateCommentFloorById(comment._id, i + 1, function(err,docc){
if (err) { // if (err) {
console.error(err); // console.error(err);
// callback(err,null); // // callback(err,null);
} else { // } else {
callback(null,null); // console.log('update '+i+1+' comment');
} // // callback(null,null);
// }
})
}); // })
} // });
} // }
], function(err, resultsss) { // }
if (err) { // ], function(err, resultsss) {
console.error(err); // if (err) {
// callback(err,null); // console.error(err);
} else { // // callback(err,null);
// callback2(null,null); // } else {
} // // callback2(null,null);
}); // }
}); // });
// });
});
async.parallel(asyncTasks, function(err, results) { // });
if (err) { // async.parallel(asyncTasks, function(err, results) {
console.error(err); // if (err) {
res.json(returnCode.BUSY); // console.error(err);
} else { // res.json(returnCode.BUSY);
// console.log("------------update done!-------------"); // } else {
res.json(returnCode.SUCCESS); // // console.log("------------update done!-------------");
} // res.json(returnCode.SUCCESS);
}); // }
}); // });
}); // });
// });
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