From 1ea35324c1d0df35eba3b234fdd6a0254aa5f4e4 Mon Sep 17 00:00:00 2001 From: lealife Date: Sat, 10 Oct 2015 15:20:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=85=E5=AE=B9=E7=9A=84IsBlog=E6=B2=A1?= =?UTF-8?q?=E6=9C=89note=20IsBlog=E4=B8=80=E8=87=B4,=20=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E5=88=A4=E6=96=AD=E6=9C=89=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/NoteService.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/service/NoteService.go b/app/service/NoteService.go index cd784f8..e06792a 100644 --- a/app/service/NoteService.go +++ b/app/service/NoteService.go @@ -430,7 +430,7 @@ func (this *NoteService) UpdateNote(updatedUserId, noteId string, needUpdate bso if isBlog, ok := needUpdate["IsBlog"]; ok { isBlog2 := isBlog.(bool) if note.IsBlog != isBlog2 { - db.UpdateByIdAndUserIdMap(db.NoteContents, noteId, userId, bson.M{"IsBlog": isBlog2}) + this.UpdateNoteContentIsBlog(noteId, userId, isBlog2); // 重新发布成博客 if !note.IsBlog { @@ -471,6 +471,11 @@ func (this *NoteService) UpdateNote(updatedUserId, noteId string, needUpdate bso return true, "", afterUsn } +// 当设置/取消了笔记为博客 +func (this *NoteService) UpdateNoteContentIsBlog(noteId, userId string, isBlog bool) { + db.UpdateByIdAndUserIdMap(db.NoteContents, noteId, userId, bson.M{"IsBlog": isBlog}) +} + // 附件修改, 增加noteIncr func (this *NoteService) IncrNoteUsn(noteId, userId string) int { afterUsn := userService.IncrUsn(userId) @@ -584,6 +589,8 @@ func (this *NoteService) ToBlog(userId, noteId string, isBlog, isTop bool) bool ok := db.UpdateByIdAndUserIdMap(db.Notes, noteId, userId, noteUpdate) // 重新计算tags go (func() { + this.UpdateNoteContentIsBlog(noteId, userId, isBlog); + blogService.ReCountBlogTags(userId) })() return ok