Commit 52ef817b authored by strong's avatar strong

Merge commit 'daa1a662' into SANDBOX

parents f291758c daa1a662
...@@ -24,6 +24,7 @@ var user = require('../../utils/user'); ...@@ -24,6 +24,7 @@ var user = require('../../utils/user');
var floorGenerator = require('../../utils/floorGenerator'); var floorGenerator = require('../../utils/floorGenerator');
var async = require('async'); var async = require('async');
var ForumModeratorApply = mongoose.model('ForumModeratorApply'); var ForumModeratorApply = mongoose.model('ForumModeratorApply');
var forumModeratorApplyService = require('../../service/forumModeratorApplyService');
var redisThreadList = require('../../utils/redisThreadList'); var redisThreadList = require('../../utils/redisThreadList');
module.exports = function(app) { module.exports = function(app) {
app.use('/v1/forum', router); app.use('/v1/forum', router);
...@@ -1210,7 +1211,7 @@ router.post('/thread/:tid/comment/:cid/create', function(req, res, next) { ...@@ -1210,7 +1211,7 @@ router.post('/thread/:tid/comment/:cid/create', function(req, res, next) {
} }
}); });
}); });
//更改评论状态为3(删除) //更改评论状态为2(删除)
router.post('/thread/:tid/comment/:cid/disable', function(req, res, next) { router.post('/thread/:tid/comment/:cid/disable', function(req, res, next) {
var user_id = user.getMobileUser(req), var user_id = user.getMobileUser(req),
tid = req.params.tid, tid = req.params.tid,
...@@ -1259,29 +1260,44 @@ router.post('/thread/:tid/comment/:cid/slash', function(req, res, next) { ...@@ -1259,29 +1260,44 @@ router.post('/thread/:tid/comment/:cid/slash', function(req, res, next) {
}, { }, {
recommend: null recommend: null
}]; }];
ForumThread.findOne(q1).populate('from').exec(function(err, t) {
if (err || !t) { async.waterfall([
return res.json(returnCode.BUSY); function(callback) {
} forumThreadService.getByConditions(q1, function(err, doc) { //查询文章
if(!t.info){//没有板块id直接返回 if (err || !doc || !doc.info) {
return res.json(returnCode.BUSY); callback(err, null);
} else {
callback(null, doc);
} }
});
},
function(thread, callback) {
var q2 = {};//查询当前用户是不是这篇文章的版主 var q2 = {};//查询当前用户是不是这篇文章的版主
q2.status=1; q2.status=1;
q2.ent_code = entCode; q2.ent_code = entCode;
q2.forumUser=userid; q2.forumUser=userid;
q2.infoIds={$all:[t.info]}; q2.infoIds={$all:[thread.info]};
ForumModeratorApply.findOne(q2).populate('forumUser').exec(function(err,result){ forumModeratorApplyService.getForumModeratorApplyByConditions(q2, function(err, doc) {
if(err){ if (err) {
return res.json(returnCode.BUSY); callback(err, null);
} } else {
if(!result){//不是该版主 callback(null, doc);
return res.json(returnCode.ACTION_NOT_PERMISSION);
} }
// });
},
function(forumModerator, callback) { //查询评论
forumCommentService.getCommentById(cid, function(err, comment) { forumCommentService.getCommentById(cid, function(err, comment) {
if (comment && userid) { if (err) {
//屏蔽 callback(err, null, null);
} else {
callback(null, forumModerator, comment);
}
});
}
], function(err, forumModerator, comment) {
if(err){
res.json(returnCode.BUSY);
} else if(forumModerator && comment){ //版主屏蔽
forumCommentService.changeStatus(cid, 0, function(err, update) { forumCommentService.changeStatus(cid, 0, function(err, update) {
if (err) { if (err) {
res.json(returnCode.BUSY); res.json(returnCode.BUSY);
...@@ -1292,11 +1308,27 @@ router.post('/thread/:tid/comment/:cid/slash', function(req, res, next) { ...@@ -1292,11 +1308,27 @@ router.post('/thread/:tid/comment/:cid/slash', function(req, res, next) {
res.json(returnCode.SUCCESS); res.json(returnCode.SUCCESS);
} }
}); });
}else{ }else if(comment && userid){ //用户自己屏蔽
res.json(returnCode.WRONG_PARAM); if (comment.from.toString() == userid.toString()) {
forumCommentService.changeStatus(cid, 0, function(err, update) {
if (err) {
res.json(returnCode.BUSY);
} else {
if (comment && comment.level == 1) {
forumAboutMEService.updateCommentLevel1Status(comment._id, 2);
}
if (comment && comment.level == 2) {
forumAboutMEService.updateCommentLevel2Status(comment._id, 2);
}
res.json(returnCode.SUCCESS);
} }
}); });
}); } else {
res.json(returnCode.ACTION_NOT_PERMISSION);
}
}else{
res.json(returnCode.BUSY);
}
}); });
}); });
...@@ -2101,7 +2133,7 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) { ...@@ -2101,7 +2133,7 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
if (tid) { if (tid) {
async.waterfall([ async.waterfall([
function(callback) { function(callback) {
forumThreadService.getByIdSelectyField(tid, 'type', function(err, thread) { forumThreadService.getByConditionsSelectyField({_id:tid}, 'type', function(err, thread) {
if (err) { if (err) {
console.error(err); console.error(err);
callback(err, null); callback(err, null);
......
...@@ -112,4 +112,16 @@ exports.getForumModeratorApplys = function(conditions, pageNo, pageSize, sort, c ...@@ -112,4 +112,16 @@ exports.getForumModeratorApplys = function(conditions, pageNo, pageSize, sort, c
}); });
}; };
//获取条件获取
exports.getForumModeratorApplyByConditions = function(conditions, callback) {
forumModeratorApply.findOne(conditions, function(err, doc) {
if (err) {
console.error(err);
callback(err, null);
} else {
callback(null, doc);
}
});
};
...@@ -248,8 +248,8 @@ exports.createThread = function(entity, callback) { ...@@ -248,8 +248,8 @@ exports.createThread = function(entity, callback) {
}; };
//根据ID获取文章,选择字段 //根据ID获取文章,选择字段
exports.getByIdSelectyField = function(id, fields, callback) { exports.getByConditionsSelectyField = function(conditions, fields, callback) {
ForumThread.findOne({_id: id}).select(fields).exec(function(err,result){ ForumThread.findOne(conditions).select(fields).exec(function(err,result){
if (err) { if (err) {
console.error(err); console.error(err);
callback(err, null); callback(err, null);
......
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