Commit 5a5356b8 authored by strong's avatar strong

Merge branch '0911_AboutMe'

parents 2bc7339e d216a1d9
......@@ -953,10 +953,10 @@ router.post('/thread/:tid/comment/:cid/disable', function(req, res, next) {
res.json(returnCode.BUSY);
} else {
if(comment && comment.level==1){
forumAboutMEService.updateCommentLevel1Status(comment._id,comment.status);
forumAboutMEService.updateCommentLevel1Status(comment._id,2);
}
if(comment && comment.level==2){
forumAboutMEService.updateCommentLevel2Status(comment._id,comment.status);
forumAboutMEService.updateCommentLevel2Status(comment._id,2);
}
res.json(returnCode.SUCCESS);
}
......@@ -1053,6 +1053,62 @@ router.get('/thread/:tid/comment/list', function(req, res, next) {
}
});
router.get('/thread/:tid/comment/list/byFloor', function(req, res, next) {
var tid = req.params.tid || null;
var floor = req.query.floor || 1;
// var conditions = {
// ent_code: req.session.user.ent_code,
// thread: tid,
// level: '1',
// status:1
// };
var countConditions = {
ent_code: req.session.user.ent_code,
thread: tid,
level: '1'
};
var conditions = {
ent_code: req.session.user.ent_code,
thread: tid,
level: '1',
floor: {
'$gte': floor - 9,
'$lte': floor
}
};
//conditions.floor['$lte'] = 12;
if (tid) {
//获取最新5条评论
forumCommentService.count(countConditions, function(err, count) {
if (err) {
console.log(err);
res.json(returnCode.BUSY);
} else {
forumCommentService.getAllComment(conditions, 1, 10, function(err, results) {
if (err) {
console.log(err);
res.json(returnCode.BUSY);
} else {
results.total = count;
res.json(_.assign(results, returnCode.SUCCESS));
}
});
}
});
} else {
res.json(returnCode.WRONG_PARAM);
}
});
//评论点赞
router.post('/thread/:tid/comment/:cid/raise', function(req, res, next) {
var userId = req.session.mobileForumUser.userId;
......
......@@ -23,6 +23,7 @@ var ForumAboutMeSchema = new Schema({
},
type:{//分类 1帖子 2一级评论 3二级评论
type: Number,
index: true,
require: true,
default: 0
},
......@@ -50,6 +51,11 @@ var ForumAboutMeSchema = new Schema({
index: true,
ref: 'ForumComment'
},
commentLevel2ThreadFrom:{//二级评论对应的帖子的发帖人
type: Schema.Types.ObjectId,
require: false,
ref: 'ForumUser'
},
commentLevel2Status:{
type: Number
},
......
......@@ -53,6 +53,7 @@ exports.saveCommentLevel2=function(tid,commentLevel1,commentLevel2){
commentLevel1:commentLevel1._id,
commentLevel1Status:commentLevel1.status,
commentLevel2:commentLevel2._id,
commentLevel2ThreadFrom:thread.from,
commentLevel2Status:commentLevel2.status,
created:new Date()
});
......@@ -87,6 +88,7 @@ exports.saveCommentLevel2BySearch=function(tid,l1id,l2id){
commentLevel1:commentLevel1._id,
commentLevel1Status:commentLevel1.status,
commentLevel2:commentLevel2._id,
commentLevel2ThreadFrom:thread.from,
commentLevel2Status:commentLevel2.status,
created:new Date()
});
......@@ -201,7 +203,7 @@ exports.me2other=function(ent_code,id,pageNo,pageSize,callback){
var limit = count - skip > pageSize ? pageSize : (count - skip);
var sortBy = '-created';
ForumAboutMe.find(condition).populate({
path: 'from to',
path: 'from to commentLevel2ThreadFrom',
select: 'uid nickName icon displayName displayIcon classLevel'
}).populate({
path: 'thread',
......@@ -245,7 +247,7 @@ exports.other2me=function(ent_code,id,pageNo,pageSize,callback){
var limit = count - skip > pageSize ? pageSize : (count - skip);
var sortBy = '-created';
ForumAboutMe.find(condition).populate({
path: 'from to',
path: 'from to commentLevel2ThreadFrom',
select: 'uid nickName icon displayName displayIcon classLevel'
}).populate({
path: 'thread',
......
......@@ -250,7 +250,7 @@ exports.getThreadById = function(tid, callback) {
var hotPhotos = results[4] || []; //最热照片墙列表
var canyuPeopleCount = results[5] || 0; //参与人数
var threadObj = thread.toObject();
var threadObj = thread && thread.toObject() || {};
threadObj.comments = comments;
threadObj.subThreads = subThreads;
threadObj.latestPhotos = latestPhotos;
......
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