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) { ...@@ -564,16 +564,27 @@ router.get('/thread/:tid/get', function(req, res, next) {
console.error(err); console.error(err);
res.json(returnCode.BUSY); res.json(returnCode.BUSY);
} else { } 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 = []; var threads = [];
threads.push(thread); threads.push(thread);
util.loadLevel(req.session.user.ent_code, threads, function() { util.loadLevel(req.session.user.ent_code, threads, function() {
if (threads && threads.length > 0) { if (threads && threads.length > 0) {
thread = threads[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) { 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() { util.loadLevel(req.session.user.ent_code, thread.subThreads.items, function() {
redisPraiseLog.get(ent_code, user.getMobileUser(req), 'thread', function(error, docs) { redisPraiseLog.get(ent_code, user.getMobileUser(req), 'thread', function(error, docs) {
if (thread.toObject) { if (thread.toObject) {
...@@ -1953,6 +1964,7 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) { ...@@ -1953,6 +1964,7 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
function(callback) { function(callback) {
forumThreadService.getByIdSelectyField(tid, 'type', function(err, thread) { forumThreadService.getByIdSelectyField(tid, 'type', function(err, thread) {
if (err) { if (err) {
console.error(err);
callback(err, null); callback(err, null);
} else { } else {
callback(null, thread); callback(null, thread);
...@@ -1962,6 +1974,7 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) { ...@@ -1962,6 +1974,7 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
function(thread, callback) { function(thread, callback) {
forumUserThreadControlService.getUserThreadControlById(user.getMobileUser(req), function(err, doc) { forumUserThreadControlService.getUserThreadControlById(user.getMobileUser(req), function(err, doc) {
if (err) { if (err) {
console.error(err);
callback(err, null, null); callback(err, null, null);
} else { } else {
if (doc) { if (doc) {
...@@ -1994,13 +2007,18 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) { ...@@ -1994,13 +2007,18 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
} }
], function(err, results) { ], function(err, results) {
if (err) { if (err) {
console.error(err);
res.json(returnCode.BUSY); res.json(returnCode.BUSY);
} else { } else {
util.loadLevel(ent_code, results.items, function() { if(results){
handleThreadList(req, results, ent_code, function(result){ util.loadLevel(ent_code, results.items, function() {
res.json(_.assign(result, returnCode.SUCCESS)); handleThreadList(req, results, ent_code, function(result){
res.json(_.assign(result, returnCode.SUCCESS));
});
}); });
}); }else{
res.json(returnCode.SUCCESS);
}
} }
}); });
} else { } else {
......
...@@ -285,7 +285,14 @@ exports.getByConditions = function(conditions, callback) { ...@@ -285,7 +285,14 @@ exports.getByConditions = function(conditions, callback) {
} }
//根据ID获取文章 //根据ID获取文章
exports.getThreadById = function(tid, callback) { 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) { if (err) {
console.error(err); console.error(err);
callback(err, null); callback(err, null);
...@@ -569,25 +576,6 @@ exports.updateThreadById = function(tid, entity, callback) { ...@@ -569,25 +576,6 @@ exports.updateThreadById = function(tid, entity, callback) {
entity.share = ''; entity.share = '';
} }
if (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) { findOneAndUpdate({_id: tid}, entity, 'updateRedisRecommentThreads', function(err, result) {
if (err) { if (err) {
console.error(err); console.error(err);
...@@ -622,32 +610,12 @@ exports.updateThreadById = function(tid, entity, callback) { ...@@ -622,32 +610,12 @@ exports.updateThreadById = function(tid, entity, callback) {
}); });
} else { } else {
delete entity.share; 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) { findOneAndUpdate({_id: tid}, entity, 'updateRedisRecommentThreads', function(err, result) {
if (err) { if (err) {
console.error(err); console.error(err);
callback(err, null); callback(err, null);
} else { } else {
ForumShare.update({_id: shareEntity._id}, shareEntity, null, function(err, se) { callback(null, entity);
if (err) {
console.error(err);
callback(err, null);
} else {
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