Commit fa46f642 authored by strong's avatar strong

Merge commit '8d924e48' into SANDBOX

parents 1b50346c 8d924e48
......@@ -564,16 +564,27 @@ router.get('/thread/:tid/get', function(req, res, next) {
console.error(err);
res.json(returnCode.BUSY);
} else {
if (thread.toObject) {
thread = thread.toObject();
}
//获取等级最高的荣誉
if(thread.from && thread.from.honorTitles && thread.from.honorTitles.length > 0){
var temp_honorTitles = _.sortBy(thread.from.honorTitles, 'order_idx');
for(var m = temp_honorTitles.length - 1; m >= 0; m-=1){
var honor = temp_honorTitles[m]
if(honor.is_show == 1){
thread.from.honorTitles = honor;
break;
}
}
}
var threads = [];
threads.push(thread);
util.loadLevel(req.session.user.ent_code, threads, function() {
if (threads && threads.length > 0) {
thread = threads[0];
}
//console.log(thread);
//console.log(thread.type == 2 && thread.level == 1&&thread.subThreads.items.length>0);
if (thread.type == 2 && thread.level == 1&&thread.subThreads.items.length>0) {
//console.log(thread.subThreads);
util.loadLevel(req.session.user.ent_code, thread.subThreads.items, function() {
redisPraiseLog.get(ent_code, user.getMobileUser(req), 'thread', function(error, docs) {
if (thread.toObject) {
......@@ -1953,6 +1964,7 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
function(callback) {
forumThreadService.getByIdSelectyField(tid, 'type', function(err, thread) {
if (err) {
console.error(err);
callback(err, null);
} else {
callback(null, thread);
......@@ -1962,6 +1974,7 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
function(thread, callback) {
forumUserThreadControlService.getUserThreadControlById(user.getMobileUser(req), function(err, doc) {
if (err) {
console.error(err);
callback(err, null, null);
} else {
if (doc) {
......@@ -1994,13 +2007,18 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
}
], function(err, results) {
if (err) {
console.error(err);
res.json(returnCode.BUSY);
} else {
util.loadLevel(ent_code, results.items, function() {
handleThreadList(req, results, ent_code, function(result){
res.json(_.assign(result, returnCode.SUCCESS));
if(results){
util.loadLevel(ent_code, results.items, function() {
handleThreadList(req, results, ent_code, function(result){
res.json(_.assign(result, returnCode.SUCCESS));
});
});
});
}else{
res.json(returnCode.SUCCESS);
}
}
});
} else {
......
......@@ -285,7 +285,14 @@ exports.getByConditions = function(conditions, callback) {
}
//根据ID获取文章
exports.getThreadById = function(tid, callback) {
ForumThread.findOne({_id: tid}).populate('from','uid mid nickName icon exp').populate('info','name icon').populate('share').exec(function(err, doc) {
ForumThread.findOne({_id: tid}).populate({
path: 'from',
select: 'uid mid nickName icon exp honorTitles',
options: {
populate:"honorTitles" //继续查荣誉
}
}).populate('info','name icon').populate('share').exec(function(err, doc) {
if (err) {
console.error(err);
callback(err, null);
......@@ -569,25 +576,6 @@ exports.updateThreadById = function(tid, entity, callback) {
entity.share = '';
}
if (entity.share) {
// ForumThread.update({
// _id: tid
// }, entity, null, function(err, result) {
// if (err) {
// console.error(err);
// callback(err, null);
// } else {
// ForumShare.update({
// _id: shareEntity._id
// }, shareEntity, null, function(err, se) {
// if (err) {
// console.error(err);
// callback(err, null);
// } else {
// callback(null, entity);
// }
// });
// }
// });
findOneAndUpdate({_id: tid}, entity, 'updateRedisRecommentThreads', function(err, result) {
if (err) {
console.error(err);
......@@ -622,32 +610,12 @@ exports.updateThreadById = function(tid, entity, callback) {
});
} else {
delete entity.share;
// ForumThread.update({
// _id: tid
// }, entity, null, function(err, result) {
// if (err) {
// console.error(err);
// callback(err, null);
// } else {
// callback(null, entity);
// }
// });
findOneAndUpdate({_id: tid}, entity, 'updateRedisRecommentThreads', function(err, result) {
if (err) {
console.error(err);
callback(err, null);
} else {
ForumShare.update({_id: shareEntity._id}, shareEntity, null, function(err, se) {
if (err) {
console.error(err);
callback(err, null);
} else {
callback(null, entity);
}
});
callback(null, entity);
}
});
......
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