Commit 811fcebd authored by 杨翌文's avatar 杨翌文

优化查询版块的逻辑

parent d001a011
...@@ -68,18 +68,13 @@ router.get('/info/:fid/get', function(req, res, next) { ...@@ -68,18 +68,13 @@ router.get('/info/:fid/get', function(req, res, next) {
if (fid) { if (fid) {
var source = req.session.mobileForumUser.source; var source = req.session.mobileForumUser.source;
httpService.createLog(req, source, fid, 2); httpService.createLog(req, source, fid, 2);
async.waterfall([ forumInfoService.updateInfoPvCount(fid, function(err, result) {
if (err) {
console.error(err);
}
});
async.parallel([
function(callback) { function(callback) {
//更新浏览数
forumInfoService.updateInfoPvCount(fid, function(err, result) {
if (err) {
callback(err, null);
} else {
callback(null, null);
}
});
},
function(data, callback) {
forumInfoService.getInfoById(fid, function(err, info) { forumInfoService.getInfoById(fid, function(err, info) {
if (err) { if (err) {
callback(err, null); callback(err, null);
...@@ -93,20 +88,20 @@ router.get('/info/:fid/get', function(req, res, next) { ...@@ -93,20 +88,20 @@ router.get('/info/:fid/get', function(req, res, next) {
info: fid info: fid
}, function(err, threadCount) { }, function(err, threadCount) {
if (err) { if (err) {
callback(err, null, null); callback(err, null);
} else { } else {
callback(null, info, threadCount); callback(null, threadCount);
} }
}); });
} }
], function(err, info, threadCount) { ], function(err, results) {
if (err) { if (err) {
console.error(err); console.error(err);
res.json(returnCode.BUSY); res.json(returnCode.BUSY);
} else { } else {
var rs = {}; var rs = {};
rs.data = info; rs.data = results[0];
rs.data.threadCount = threadCount; rs.data.threadCount = results[1];
res.json(_.assign(rs, returnCode.SUCCESS)); res.json(_.assign(rs, 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