Commit b47a2d08 authored by 陈家荣's avatar 陈家荣

ggg

parent 1981c34d
...@@ -38,7 +38,6 @@ exports.updateCommentStatusById=function(cid,status,callback){ ...@@ -38,7 +38,6 @@ exports.updateCommentStatusById=function(cid,status,callback){
console.error(err); console.error(err);
callback(err,null); callback(err,null);
} else { } else {
console.log(result);
callback(null,null); callback(null,null);
} }
}); });
...@@ -51,7 +50,6 @@ exports.updateCommentById=function(cid,entity,callback){ ...@@ -51,7 +50,6 @@ exports.updateCommentById=function(cid,entity,callback){
console.error(err); console.error(err);
callback(err,null); callback(err,null);
} else { } else {
console.log(result);
callback(null,null); callback(null,null);
} }
}); });
...@@ -84,6 +82,7 @@ function countAll(conditions,callback) { ...@@ -84,6 +82,7 @@ function countAll(conditions,callback) {
//获取全部列表数据 //获取全部列表数据
exports.getAllComment= function(conditions,pageNo,pageSize,callback) { exports.getAllComment= function(conditions,pageNo,pageSize,callback) {
countAll(conditions,function(err,count){ countAll(conditions,function(err,count){
if(err){ if(err){
console.error(err); console.error(err);
...@@ -91,7 +90,7 @@ exports.getAllComment= function(conditions,pageNo,pageSize,callback) { ...@@ -91,7 +90,7 @@ exports.getAllComment= function(conditions,pageNo,pageSize,callback) {
}else{ }else{
var skip = (pageNo - 1) * pageSize; var skip = (pageNo - 1) * pageSize;
var limit = count - skip > pageSize ? pageSize : (count - skip); var limit = count - skip > pageSize ? pageSize : (count - skip);
console.log("count:" + count);
ForumComment.find(conditions).populate('from').populate('to').limit(limit).skip(skip).sort('-created').exec(function(err, docs) { ForumComment.find(conditions).populate('from').populate('to').limit(limit).skip(skip).sort('-created').exec(function(err, docs) {
if (err) { if (err) {
console.error(err); console.error(err);
...@@ -199,3 +198,21 @@ exports.updateCommentCount=function(cid,callback){ ...@@ -199,3 +198,21 @@ exports.updateCommentCount=function(cid,callback){
} }
}); });
}; };
// 查找数组元素下标
function indexOf(array,val) {
for (var i = 0; i < array.length; i++) {
if (array[i] == val) return i;
}
return -1;
};
// 删除数组指定值
exports.remove = function(array,val) {
var index = indexOf(array,val);
if (index > -1) {
array.splice(index, 1);
}
return array;
};
\ No newline at end of file
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