Commit 634b8020 authored by 陈家荣's avatar 陈家荣

更新屏蔽文章的状态

parent 80a3d60a
...@@ -1896,7 +1896,7 @@ router.get('/thread/:tid/hotPhotos', function(req, res, next) { ...@@ -1896,7 +1896,7 @@ router.get('/thread/:tid/hotPhotos', function(req, res, next) {
}); });
//逻辑删除文章 //屏蔽文章
router.post('/thread/:tid/disable', function(req, res, next) { router.post('/thread/:tid/disable', function(req, res, next) {
var user_id = user.getMobileUser(req); var user_id = user.getMobileUser(req);
var tid = req.params.tid; var tid = req.params.tid;
...@@ -1904,11 +1904,20 @@ router.post('/thread/:tid/disable', function(req, res, next) { ...@@ -1904,11 +1904,20 @@ router.post('/thread/:tid/disable', function(req, res, next) {
forumThreadService.getThreadById(tid, function(err, thread) { forumThreadService.getThreadById(tid, function(err, thread) {
if (thread.from && user_id) { if (thread.from && user_id) {
if (thread.from._id.toString() == user_id.toString()) { if (thread.from._id.toString() == user_id.toString()) {
forumThreadService.logicDeleteThreadById(tid, function(err, flag) { // forumThreadService.logicDeleteThreadById(tid, function(err, flag) {
// if (err) {
// res.json(returnCode.BUSY);
// } else {
// forumAboutMEService.updateThreadStatus(tid, 3);
// res.json(returnCode.SUCCESS);
// }
// });
forumThreadService.updateThread(tid, {status : 0},function(err, flag) {
if (err) { if (err) {
res.json(returnCode.BUSY); res.json(returnCode.BUSY);
} else { } else {
forumAboutMEService.updateThreadStatus(tid, 3); forumAboutMEService.updateThreadStatus(tid, 0);
res.json(returnCode.SUCCESS); res.json(returnCode.SUCCESS);
} }
}); });
......
...@@ -634,18 +634,6 @@ exports.updateThreadById = function(tid, entity, callback) { ...@@ -634,18 +634,6 @@ exports.updateThreadById = function(tid, entity, callback) {
//逻辑删除文章 //逻辑删除文章
exports.logicDeleteThreadById = function(tid, 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) { findOneAndUpdate({_id: mongoose.Types.ObjectId(tid)}, {status : 3}, 'updateRedisRecommentThreads', function(err, result) {
if (err) { if (err) {
console.error(err); console.error(err);
...@@ -656,6 +644,18 @@ exports.logicDeleteThreadById = function(tid, callback) { ...@@ -656,6 +644,18 @@ exports.logicDeleteThreadById = function(tid, callback) {
}); });
}; };
//更新文章
exports.updateThread = function(tid, entity, callback) {
findOneAndUpdate({_id: mongoose.Types.ObjectId(tid)}, entity, 'updateRedisRecommentThreads', function(err, result) {
if (err) {
console.error(err);
callback(err, false);
} else {
callback(null, true);
}
});
};
//根据ID删除文章 //根据ID删除文章
exports.deleteThreadById = function(tid, callback) { exports.deleteThreadById = function(tid, 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