Commit 7059dc89 authored by 邓军's avatar 邓军

子文章管理

parent 114142af
......@@ -10,7 +10,7 @@ var async = require('async');
var then = require('thenjs');
//查询帖子
exports.findThreadByPage = function(pageNo,pageSize,q,callback) {
exports.findThreadByPage = function(pageNo, pageSize, q, callback) {
then(function(cont) {
ForumThread.find(q).populate('from').count(cont);
}).then(function(cont, count) {
......@@ -26,7 +26,7 @@ exports.findThreadByPage = function(pageNo,pageSize,q,callback) {
total: count,
datas: threads
};
callback(null,rsJson);
callback(null, rsJson);
}).fail(function(cont, err) {
console.error(err);
......@@ -34,12 +34,12 @@ exports.findThreadByPage = function(pageNo,pageSize,q,callback) {
result: false,
err: err
};
callback(err,rsJson);
callback(err, rsJson);
});
};
//查询评论
exports.findCommentByPage = function(pageNo,pageSize,q,callback) {
exports.findCommentByPage = function(pageNo, pageSize, q, callback) {
then(function(cont) {
ForumComment.find(q).populate('from').count(cont);
......@@ -56,7 +56,7 @@ exports.findCommentByPage = function(pageNo,pageSize,q,callback) {
total: count,
datas: threads
};
callback(null,rsJson);
callback(null, rsJson);
}).fail(function(cont, err) {
console.error(err);
......@@ -64,7 +64,7 @@ exports.findCommentByPage = function(pageNo,pageSize,q,callback) {
result: false,
err: err
};
callback(err,rsJson);
callback(err, rsJson);
});
};
......@@ -254,8 +254,13 @@ exports.getThreadById = function(tid, callback) {
//根据ID更新文章
exports.updateThreadById = function(tid, entity, callback) {
var shareEntity = entity.share;
if (entity.share._id) {
entity.share = entity.share._id;
}else{
entity.share = '';
}
if (entity.share) {
ForumThread.update({
_id: tid
}, entity, null, function(err, result) {
......@@ -265,12 +270,12 @@ exports.updateThreadById = function(tid, entity, callback) {
} else {
ForumShare.update({
_id: shareEntity._id
}, shareEntity, null, function(err, result) {
}, shareEntity, null, function(err, se) {
if (err) {
console.error(err);
callback(err, null);
} else {
callback(null, null);
callback(null, entity);
}
});
......@@ -291,7 +296,7 @@ exports.updateThreadById = function(tid, entity, callback) {
console.error(err);
callback(err, null);
} else {
callback(null, null);
callback(null, entity);
}
});
......@@ -305,7 +310,7 @@ exports.updateThreadById = function(tid, entity, callback) {
console.error(err);
callback(err, null);
} else {
callback(null, null);
callback(null, entity);
}
});
......
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