diff --git a/app/service/NoteService.go b/app/service/NoteService.go index 90334c1..ef22248 100644 --- a/app/service/NoteService.go +++ b/app/service/NoteService.go @@ -438,11 +438,7 @@ func (this *NoteService) UpdateNote(updatedUserId, noteId string, needUpdate bso afterUsn := userService.IncrUsn(userId) needUpdate["Usn"] = afterUsn - // 添加tag2 - // TODO 这个tag去掉, 添加tag另外添加, 不要这个 - if tags, ok := needUpdate["Tags"]; ok { - tagService.AddTagsI(userId, tags) - } + needRecountTags := false // 是否修改了isBlog // 也要修改noteContents的IsBlog @@ -456,10 +452,18 @@ func (this *NoteService) UpdateNote(updatedUserId, noteId string, needUpdate bso needUpdate["PublicTime"] = needUpdate["UpdatedTime"] } - // 重新计算tags - go (func() { - blogService.ReCountBlogTags(userId) - })() + needRecountTags = true + } + } + + // 添加tag2 + // TODO 这个tag去掉, 添加tag另外添加, 不要这个 + if tags, ok := needUpdate["Tags"]; ok { + tagService.AddTagsI(userId, tags) + + // 如果是博客, 标签改了, 那么重新计算 + if note.IsBlog { + needRecountTags = true } } @@ -468,6 +472,13 @@ func (this *NoteService) UpdateNote(updatedUserId, noteId string, needUpdate bso return ok, "", 0 } + if needRecountTags { + // 重新计算tags + go (func() { + blogService.ReCountBlogTags(userId) + })() + } + // 重新获取之 note = this.GetNoteById(noteId)