Commit ce39b4d9 authored by strong's avatar strong

Merge branch 'newfunc_0321_personal_site'

parents fb5f5398 6867bbc2
......@@ -21,7 +21,7 @@ module.exports = function(app) {
//分页用户查询消息
router.get('/message/searchMesage', function(req, res, next) {
//参数
var pageNo = req.query.pageNo || 1,
var pageNo = req.query.pageNo || 0,
pageSize = req.query.pageSize || 10,
from = user.getMobileUser(req),
ent_code = req.session.user.ent_code;
......
......@@ -1896,7 +1896,7 @@ router.get('/thread/:tid/hotPhotos', function(req, res, next) {
});
//逻辑删除文章
//屏蔽文章
router.post('/thread/:tid/disable', function(req, res, next) {
var user_id = user.getMobileUser(req);
var tid = req.params.tid;
......@@ -1904,11 +1904,11 @@ 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) {
forumThreadService.updateThreadById_2(tid, {status : 0},function(err, flag) {
if (err) {
res.json(returnCode.BUSY);
} else {
forumAboutMEService.updateThreadStatus(tid, 3);
forumAboutMEService.updateThreadStatus(tid, 0);
res.json(returnCode.SUCCESS);
}
});
......
......@@ -196,7 +196,6 @@ exports.getMessages= function(conditions, status, pageNo, pageSize, callback) {
var skip = pageNo * pageSize;
var limit = total - skip > pageSize ? pageSize : (total - skip);
limit = parseInt(limit) + parseInt(skip);
//获取分页后的数组
messages = messages.slice(skip,limit);
callback(null,total,messages);
......@@ -249,7 +248,10 @@ exports.updateUserMessageStatus= function(condition,msgID, status,callback) {
//前端根据ID获取
exports.getByIdWithSelect=function(mid,callback){
ForumMessage.findOne({_id:mid}).select('_id fromNickName from title content created status').exec(function(err, doc) {
ForumMessage.findOne({_id:mid}).select('_id fromNickName from title content created status').populate({
path: 'from',
select: 'nickName icon'
}).exec(function(err, doc) {
if (err) {
console.error(err);
callback(err,null);
......
......@@ -634,18 +634,6 @@ exports.updateThreadById = function(tid, entity, callback) {
//逻辑删除文章
exports.logicDeleteThreadById = function(tid, callback) {
// ForumThread.update({
// _id: mongoose.Types.ObjectId(tid)
// }, {
// status : 3
// }, null, function(err, result) {
// if (err) {
// console.error(err);
// callback(err, false);
// } else {
// callback(null, true);
// }
// });
findOneAndUpdate({_id: mongoose.Types.ObjectId(tid)}, {status : 3}, 'updateRedisRecommentThreads', function(err, result) {
if (err) {
console.error(err);
......@@ -656,6 +644,18 @@ exports.logicDeleteThreadById = function(tid, callback) {
});
};
//更新文章
exports.updateThreadById_2 = function(tid, entity, callback) {
findOneAndUpdate({_id: tid}, entity, 'updateRedisRecommentThreads', function(err, result) {
if (err) {
console.error(err);
callback(err, false);
} else {
callback(null, true);
}
});
};
//根据ID删除文章
exports.deleteThreadById = function(tid, callback) {
......@@ -776,7 +776,51 @@ exports.getAllCountByFid = function(conditions, callback) {
function getSubThreads(doc, sort, callback) {
var conditions = {
pid: doc._id,
status: 1
status: {'$ne':3},
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 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) {
......@@ -800,6 +844,7 @@ function getSubThreads(doc, sort, callback) {
}
});
var obj = {};
obj.docTotal = docs.length;
obj.total = list.length;
obj.items = list;
......@@ -1409,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