Commit 138583f3 authored by strong's avatar strong

Merge commit '1301e611'

parents 0fb26aa0 1301e611
...@@ -108,4 +108,28 @@ router.get('/honorTitle/list', function(req, res, next) { ...@@ -108,4 +108,28 @@ router.get('/honorTitle/list', function(req, res, next) {
res.json(_.assign(result, returnCode.SUCCESS)); res.json(_.assign(result, returnCode.SUCCESS));
} }
}); });
});
//获取状态为启用的
router.get('/honorTitle/allList', function(req, res, next) {
var conditions={
ent_code:req.session.user.ent_code,
status:1
};
forumHonorTitleService.find(conditions, function(err,results){
if(err){
console.error(err);
res.json(returnCode.BUSY);
}else{
var map = {};
_.forEach(results, function(d, i) {
map[d._id] = d;
});
var rs = {
data:map
};
res.json(_.assign(rs, returnCode.SUCCESS));
}
});
}); });
\ No newline at end of file
...@@ -569,17 +569,6 @@ router.get('/thread/:tid/get', function(req, res, next) { ...@@ -569,17 +569,6 @@ router.get('/thread/:tid/get', function(req, res, next) {
if (thread.toObject) { if (thread.toObject) {
thread = 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() {
...@@ -1695,10 +1684,8 @@ router.get('/thread/:tid/topics', function(req, res, next) { ...@@ -1695,10 +1684,8 @@ router.get('/thread/:tid/topics', function(req, res, next) {
var conditions = { var conditions = {
ent_code: req.session.user.ent_code, ent_code: req.session.user.ent_code,
pid: tid, pid: tid,
type: 2, // type: 2,
status: { status: 1
$ne: 3
}
}; };
if (tid) { if (tid) {
async.waterfall([ async.waterfall([
...@@ -1750,7 +1737,7 @@ router.get('/thread/:tid/latestPhotos', function(req, res, next) { ...@@ -1750,7 +1737,7 @@ router.get('/thread/:tid/latestPhotos', function(req, res, next) {
var conditions = { var conditions = {
ent_code: ent_code, ent_code: ent_code,
pid: tid, pid: tid,
type: 3, // type: 3,
status: 1, status: 1,
images: { images: {
$exists: true, $exists: true,
...@@ -1824,7 +1811,7 @@ router.get('/thread/:tid/hotPhotos', function(req, res, next) { ...@@ -1824,7 +1811,7 @@ router.get('/thread/:tid/hotPhotos', function(req, res, next) {
var conditions = { var conditions = {
ent_code: ent_code, ent_code: ent_code,
pid: tid, pid: tid,
type: 3, // type: 3,
status: 1, status: 1,
images: { images: {
$exists: true, $exists: true,
...@@ -2064,18 +2051,6 @@ function handleThreadList(req, results, ent_code, callback){ ...@@ -2064,18 +2051,6 @@ function handleThreadList(req, results, ent_code, callback){
} }
} }
//获取等级最高的荣誉
if(results.items[i].from && results.items[i].from.honorTitles && results.items[i].from.honorTitles.length > 0){
var temp_honorTitles = _.sortBy(results.items[i].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){
results.items[i].from.honorTitles = honor;
break;
}
}
}
results.items[i].isPraise = false; results.items[i].isPraise = false;
for (var k = docs.length - 1; k >= 0; k--) { for (var k = docs.length - 1; k >= 0; k--) {
if (results.items[i]._id == docs[k]) { if (results.items[i]._id == docs[k]) {
...@@ -2144,7 +2119,7 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) { ...@@ -2144,7 +2119,7 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
var conditions = { var conditions = {
ent_code: ent_code, ent_code: ent_code,
pid: tid, pid: tid,
type: 2, // type: 2,
status: 1 status: 1
}; };
......
...@@ -144,8 +144,10 @@ exports.getAllComment = function(conditions, pageNo, pageSize, callback) { ...@@ -144,8 +144,10 @@ exports.getAllComment = function(conditions, pageNo, pageSize, callback) {
} else { } else {
var skip = (pageNo - 1) * pageSize; var skip = (pageNo - 1) * pageSize;
var limit = count - skip > pageSize ? pageSize : (count - skip); var limit = count - skip > pageSize ? pageSize : (count - skip);
ForumComment.find(conditions,listCommentFields).populate({
ForumComment.find(conditions,listCommentFields).populate('from','uid mid nickName icon exp').populate('to','uid mid nickName icon exp').limit(limit).skip(skip).sort('-created').exec(function(err, docs) { path: 'from',
select: 'uid mid nickName icon exp honorTitles'
}).populate('to','uid mid nickName icon exp').limit(limit).skip(skip).sort('-created').exec(function(err, docs) {
if (err) { if (err) {
console.error(err); console.error(err);
callback(err, null); callback(err, null);
...@@ -640,7 +642,7 @@ exports.getAllComment_allstatus = function(conditions, pageNo, pageSize, callbac ...@@ -640,7 +642,7 @@ exports.getAllComment_allstatus = function(conditions, pageNo, pageSize, callbac
var skip = (pageNo - 1) * pageSize; var skip = (pageNo - 1) * pageSize;
var limit = count - skip > pageSize ? pageSize : (count - skip); var limit = count - skip > pageSize ? pageSize : (count - skip);
ForumComment.find(conditions,listCommentFields).populate('from','uid mid nickName icon exp').populate('to','uid mid nickName icon exp').limit(limit).skip(skip).sort('-created').exec(function(err, docs) { ForumComment.find(conditions,listCommentFields).populate('from','uid mid nickName icon exp honorTitles').populate('to','uid mid nickName icon exp').limit(limit).skip(skip).sort('-created').exec(function(err, docs) {
if (err) { if (err) {
console.error(err); console.error(err);
callback(err, null); callback(err, null);
......
...@@ -9,6 +9,7 @@ var forumCommentService = require('./forumCommentService'); ...@@ -9,6 +9,7 @@ var forumCommentService = require('./forumCommentService');
var async = require('async'); var async = require('async');
var then = require('thenjs'); var then = require('thenjs');
var _ = require('lodash');
var redisThreadList = require('../utils/redisThreadList'); var redisThreadList = require('../utils/redisThreadList');
...@@ -285,13 +286,9 @@ exports.getByConditions = function(conditions, callback) { ...@@ -285,13 +286,9 @@ exports.getByConditions = function(conditions, callback) {
} }
//根据ID获取文章 //根据ID获取文章
exports.getThreadById = function(tid, callback) { exports.getThreadById = function(tid, callback) {
ForumThread.findOne({_id: tid}).populate({ ForumThread.findOne({_id: tid}).populate({
path: 'from', path: 'from',
select: 'uid mid nickName icon exp honorTitles', select: 'uid mid nickName icon exp honorTitles'
options: {
populate:"honorTitles" //继续查荣誉
}
}).populate('info','name icon').populate('share').exec(function(err, doc) { }).populate('info','name icon').populate('share').exec(function(err, doc) {
if (err) { if (err) {
console.error(err); console.error(err);
...@@ -769,30 +766,35 @@ function getSubThreads(doc, sort, callback) { ...@@ -769,30 +766,35 @@ function getSubThreads(doc, sort, callback) {
pid: doc._id, pid: doc._id,
status: 1 status: 1
}; };
countAllByFid(conditions, function(err, count) { var sortBy = '-top -quality -created';
if (sort) {
sortBy = sort;
}
ForumThread.find(conditions, subThreadFields).populate('from', 'icon').sort(sortBy).exec(function(err, docs) {
if (err) { if (err) {
console.error(err); console.error(err);
callback(err, null); callback(err, null);
} else { } else {
var sortBy = '-top -quality -created'; var list = []; //用户去重
if (sort) { _.forEach(docs, function(one, i) {
sortBy = sort; var flag = true;
} _.forEach(list, function(two, k) {
ForumThread.find(conditions, subThreadFields).populate('from', 'icon').sort(sortBy).exec(function(err, docs) { if(one.from._id == two.from._id){
if (err) { flag = false;
console.error(err); }
callback(err, null); });
} else { if(flag){
var obj = {}; list.push(one);
obj.total = count;
obj.items = docs;
var newDoc = doc.toObject();
newDoc.subThreads = obj;
callback(null, newDoc);
} }
}); });
var obj = {};
obj.total = list.length;
obj.items = list;
var newDoc = doc.toObject();
newDoc.subThreads = obj;
callback(null, newDoc);
} }
}); });
} }
...@@ -1374,10 +1376,7 @@ exports.getThreadWithNotPopulateComment = function(conditions, pageNo, pageSize, ...@@ -1374,10 +1376,7 @@ exports.getThreadWithNotPopulateComment = function(conditions, pageNo, pageSize,
} }
ForumThread.find(conditions).populate({ ForumThread.find(conditions).populate({
path: 'from', path: 'from',
select: 'uid mid nickName icon honorTitles', select: 'uid mid nickName icon honorTitles'
options: {
populate:"honorTitles" //继续查荣誉
}
}).populate('info','name icon pv_count').limit(limit).skip(skip).sort(sortBy).exec(function(err, docs) { }).populate('info','name icon pv_count').limit(limit).skip(skip).sort(sortBy).exec(function(err, docs) {
if (err) { if (err) {
console.error(err); console.error(err);
......
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