Commit 67ccf128 authored by 陈志良's avatar 陈志良

添加文章加精功能

parent 1f64524f
......@@ -211,7 +211,44 @@ router.post('/thread/:tid/:fid/unTop', function(req, res, next) {
res.json(returnCode.WRONG_PARAM);
}
});
//文章推荐
router.post('/thread/:tid/:fid/recommend', function(req, res, next) {
var tid = req.params.tid,
fid = req.params.fid,
ent_code = req.session.user.ent_code,
mid = req.params.mid; //板块ID
if (tid && fid) {
forumThreadService.updateRecommendByThreadId(tid, function(err, thread) {
if (err) {
res.json(returnCode.BUSY);
} else {
if(mid){
httpService.sendRequest(ent_code,mid,'thread_recomment');
}
res.json(returnCode.SUCCESS);
}
});
} else {
res.json(returnCode.WRONG_PARAM);
}
});
//文章取消推荐
router.post('/thread/:tid/:fid/unRecommend', function(req, res, next) {
var tid = req.params.tid; //文章ID
var fid = req.params.fid; //板块ID
if (tid && fid) {
forumThreadService.updateUnRecommendByThreadId(tid, function(err, thread) {
if (err) {
res.json(returnCode.BUSY);
} else {
res.json(returnCode.SUCCESS);
}
});
} else {
res.json(returnCode.WRONG_PARAM);
}
});
/**
* [description]
* @param {[type]}
......
......@@ -60,8 +60,8 @@ var ForumThreadSchema = new Schema({
},
topTime:{//置顶时间
type: Date
}
,tag_top: { //标签话题是否置顶0否,1是
},
tag_top: { //标签话题是否置顶0否,1是
type: Number,
require: true,
default: 0
......@@ -107,7 +107,12 @@ var ForumThreadSchema = new Schema({
type: Number,
require: true,
default: 1
},
},
recommend:{//是否推荐 0否 1是
type: Number,
require: true,
default: 0
},
created: {
type: Date,
required: true,
......
......@@ -585,7 +585,26 @@ exports.updateUnTopByThreadId = function(infoId, threadId, callback) {
}
});
};
//根据文章ID更新文章为推荐
exports.updateRecommendByThreadId = function(threadId, callback) {
ForumThread.findOneAndUpdate({
_id: threadId
}, {
recommend: 1
}, function(err, doc) {
callback(err,null);
});
};
//根据文章ID更新文章为不推荐
exports.updateUnRecommendByThreadId = function(threadId, callback) {
ForumThread.findOneAndUpdate({
_id: threadId
}, {
recommend: 0
}, function(err, doc) {
callback(err,null);
});
};
//根据板块ID更新标签置顶(置顶)
exports.updateTagTop = function(tid,tag_top,callback){
var time = '';
......
......@@ -10,7 +10,8 @@ var ACTION_KEY = {
'thread_praise': 'FORUM_THREAD_PRAISE',
'comment_praise': 'FORUM_COMMENT_PRAISE',
'reply': 'FORUM_COMMENT_REPLY',
'user_from_share': 'FORUM_USER_FROM_SHARE'
'user_from_share': 'FORUM_USER_FROM_SHARE',
'thread_recomment':'FORUM_THREAD_RECOMMENT'
};
var mongoose = require('mongoose'),
moment = require('moment'),
......
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