Commit 6867bbc2 authored by 陈家荣's avatar 陈家荣

更新社区帖子查询

parent bd7ea502
......@@ -1904,16 +1904,7 @@ router.post('/thread/:tid/disable', function(req, res, next) {
forumThreadService.getThreadById(tid, function(err, thread) {
if (thread.from && user_id) {
if (thread.from._id.toString() == user_id.toString()) {
// forumThreadService.logicDeleteThreadById(tid, function(err, flag) {
// if (err) {
// res.json(returnCode.BUSY);
// } else {
// forumAboutMEService.updateThreadStatus(tid, 3);
// res.json(returnCode.SUCCESS);
// }
// });
forumThreadService.updateThread(tid, {status : 0},function(err, flag) {
forumThreadService.updateThreadById_2(tid, {status : 0},function(err, flag) {
if (err) {
res.json(returnCode.BUSY);
} else {
......
......@@ -645,8 +645,8 @@ exports.logicDeleteThreadById = function(tid, callback) {
};
//更新文章
exports.updateThread = function(tid, entity, callback) {
findOneAndUpdate({_id: mongoose.Types.ObjectId(tid)}, entity, 'updateRedisRecommentThreads', function(err, result) {
exports.updateThreadById_2 = function(tid, entity, callback) {
findOneAndUpdate({_id: tid}, entity, 'updateRedisRecommentThreads', function(err, result) {
if (err) {
console.error(err);
callback(err, false);
......@@ -814,6 +814,48 @@ function getSubThreads(doc, sort, callback) {
});
}
//获取话题、照片墙子文章数据
function getMobileSubThreads(doc, sort, callback) {
var conditions = {
pid: doc._id,
status: 1,
level:2,
ent_code:doc.ent_code
};
var sortBy = '-top -quality -created';
if (sort) {
sortBy = sort;
}
ForumThread.find(conditions, subThreadFields).populate('from', 'icon').sort(sortBy).exec(function(err, docs) {
if (err) {
console.error(err);
callback(err, null);
} else {
var list = []; //用户去重
_.forEach(docs, function(one, i) {
var flag = true;
_.forEach(list, function(two, k) {
if(one.from._id == two.from._id){
flag = false;
}
});
if(flag){
list.push(one);
}
});
var obj = {};
obj.docTotal = docs.length;
obj.total = list.length;
obj.items = list;
var newDoc = doc.toObject();
newDoc.subThreads = obj;
callback(null, newDoc);
}
});
}
function getAllThreadByFidHelp(conditions, pageNo, pageSize, sort, callback) {
countAllByFid(conditions, function(err, count) {
if (err) {
......@@ -1412,7 +1454,7 @@ exports.getThreadWithNotPopulateComment = function(conditions, pageNo, pageSize,
});
} else {
asyncTasks.push(function(callback) {
getSubThreads(doc, null, callback);
getMobileSubThreads(doc, null, callback);
});
}
});
......
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