Commit 6f2f683b authored by 陈志良's avatar 陈志良

1

parent 6487f562
...@@ -21,12 +21,12 @@ exports.createComment=function(entity,callback){ ...@@ -21,12 +21,12 @@ exports.createComment=function(entity,callback){
//根据ID获取评论 //根据ID获取评论
exports.getCommentById=function(cid,callback){ exports.getCommentById=function(cid,callback){
ForumComment.findById(cid, function(err, thread) { ForumComment.findById(cid, function(err, comment) {
if (err) { if (err) {
console.error(err); console.error(err);
callback(err,null); callback(err,null);
} else { } else {
callback(null,thread); callback(null,comment);
} }
}); });
}; };
...@@ -232,7 +232,6 @@ exports.updateCommentCount=function(cid,callback){ ...@@ -232,7 +232,6 @@ exports.updateCommentCount=function(cid,callback){
}); });
}; };
// 查找数组元素下标 // 查找数组元素下标
function indexOf(array,val) { function indexOf(array,val) {
for (var i = 0; i < array.length; i++) { for (var i = 0; i < array.length; i++) {
...@@ -248,4 +247,14 @@ exports.remove = function(array,val) { ...@@ -248,4 +247,14 @@ exports.remove = function(array,val) {
array.splice(index, 1); array.splice(index, 1);
} }
return array; return array;
};
//更改评论状态
exports.changeStatus = function(cid,status,callback){
ForumComment.update(
{_id:cid},
{status:status},
function(err,update){
callback(err,update);
}
);
}; };
\ No newline at end of file
...@@ -141,8 +141,8 @@ exports.getThreadById = function(tid, callback) { ...@@ -141,8 +141,8 @@ exports.getThreadById = function(tid, callback) {
function(cb) { function(cb) {
var conditions = { var conditions = {
thread: tid, thread: tid,
level: '1', level: '1'
status:1 // status:1
}; };
//获取最新10条评论 //获取最新10条评论
forumCommentService.getAllComment(conditions, 1, 10, function(err, results) { forumCommentService.getAllComment(conditions, 1, 10, function(err, results) {
...@@ -270,8 +270,8 @@ exports.getThreadByIdNoLimit = function(tid, callback) { ...@@ -270,8 +270,8 @@ exports.getThreadByIdNoLimit = function(tid, callback) {
function(cb) { function(cb) {
var conditions = { var conditions = {
thread: tid, thread: tid,
level: '1', level: '1'
status:1 // status:1
}; };
//获取最新10条评论 //获取最新10条评论
forumCommentService.getAllComment(conditions, 1, 999, function(err, results) { forumCommentService.getAllComment(conditions, 1, 999, function(err, results) {
...@@ -450,7 +450,7 @@ exports.updateThreadById = function(tid, entity, callback) { ...@@ -450,7 +450,7 @@ exports.updateThreadById = function(tid, entity, callback) {
//逻辑删除文章 //逻辑删除文章
exports.logicDeleteThreadById = function(tid, callback) { exports.logicDeleteThreadById = function(tid, callback) {
ForumThread.update({ ForumThread.update({
_id: tid _id: mongoose.Types.ObjectId(tid)
}, { }, {
status : 3 status : 3
}, null, function(err, result) { }, null, function(err, result) {
......
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