批量公开, 取消公开为博客完成

This commit is contained in:
life
2015-10-24 12:26:41 +08:00
parent 17b2b9f2fa
commit 51174399d2
4 changed files with 94 additions and 51 deletions

19
node_modules/note.js generated vendored
View File

@@ -161,7 +161,22 @@ var Note = {
},
// 公开/取消为博客
setNote2Blog: function(noteId, isBlog, callback) {
setNote2Blog: function(noteIds, isBlog, callback) {
var me = this;
var ok = false;
async.eachSeries(noteIds, function(noteId, cb) {
me._setNote2Blog(noteId, isBlog, function (ret) {
if (ret) {
ok = true;
}
cb();
});
}, function () {
callback(ok);
});
},
_setNote2Blog: function(noteId, isBlog, callback) {
var me = this;
me.getNote(noteId, function(note) {
if(note) {
@@ -169,7 +184,7 @@ var Note = {
return callback && callback(true);
}
// 更新, 设置isDirty
db.notes.update({NoteId: noteId}, { $set: {IsBlog: isBlog, IsDirty: true} }, {}, function (err, numReplaced) {
db.notes.update({_id: note._id}, { $set: {IsBlog: isBlog, IsDirty: true} }, {}, function (err, numReplaced) {
return callback && callback(true);
});
} else {