本文整理匯總了Golang中github.com/leanote/leanote/app/db.UpdateByIdAndUserIdField函數的典型用法代碼示例。如果您正苦於以下問題:Golang UpdateByIdAndUserIdField函數的具體用法?Golang UpdateByIdAndUserIdField怎麽用?Golang UpdateByIdAndUserIdField使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了UpdateByIdAndUserIdField函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: UpdateNoteContent
// 修改筆記本內容
// [ok] TODO perm未測
// hasBeforeUpdateNote 之前是否更新過note其它信息, 如果有更新, usn不用更新
// TODO abstract這裏生成
func (this *NoteService) UpdateNoteContent(updatedUserId, noteId, content, abstract string,
hasBeforeUpdateNote bool,
usn int, updatedTime time.Time) (bool, string, int) {
// 是否已自定義
note := this.GetNoteById(noteId)
if note.NoteId == "" {
return false, "notExists", 0
}
userId := note.UserId.Hex()
// updatedUserId 要修改userId的note, 此時需要判斷是否有修改權限
if userId != updatedUserId {
if !shareService.HasUpdatePerm(userId, updatedUserId, noteId) {
Log("NO AUTH")
return false, "noAuth", 0
}
}
updatedTime = FixUrlTime(updatedTime)
// abstract重置
data := bson.M{"UpdatedUserId": bson.ObjectIdHex(updatedUserId),
"Content": content,
"Abstract": abstract,
"UpdatedTime": updatedTime}
if note.IsBlog && note.HasSelfDefined {
delete(data, "Abstract")
}
// usn, 修改筆記不可能單獨修改內容
afterUsn := 0
// 如果之前沒有修改note其它信息, 那麽usn++
if !hasBeforeUpdateNote {
// 需要驗證
if usn >= 0 && note.Usn != usn {
return false, "conflict", 0
}
afterUsn = userService.IncrUsn(userId)
db.UpdateByIdAndUserIdField(db.Notes, noteId, userId, "Usn", usn)
}
if db.UpdateByIdAndUserIdMap(db.NoteContents, noteId, userId, data) {
// 這裏, 添加曆史記錄
noteContentHistoryService.AddHistory(noteId, userId, info.EachHistory{UpdatedUserId: bson.ObjectIdHex(updatedUserId),
Content: content,
UpdatedTime: time.Now(),
})
// 更新筆記圖片
noteImageService.UpdateNoteImages(userId, noteId, note.ImgSrc, content)
return true, "", afterUsn
}
return false, "", 0
}
示例2: UpdateNotebookTitle
// 更新筆記本標題
// [ok]
func (this *NotebookService) UpdateNotebookTitle(notebookId, userId, title string) bool {
return db.UpdateByIdAndUserIdField(db.Notebooks, notebookId, userId, "Title", title)
}
示例3: UpdateImageTitle
func (this *FileService) UpdateImageTitle(userId, fileId, title string) bool {
return db.UpdateByIdAndUserIdField(db.Files, fileId, userId, "Title", title)
}
示例4: UpdateTags
// 更新tags
// [ok] [del]
func (this *NoteService) UpdateTags(noteId string, userId string, tags []string) bool {
return db.UpdateByIdAndUserIdField(db.Notes, noteId, userId, "Tags", tags)
}
示例5: UpdateAlbum
// update album name
func (this *AlbumService) UpdateAlbum(albumId, userId, name string) bool {
return db.UpdateByIdAndUserIdField(db.Albums, albumId, userId, "Name", name)
}
示例6: UpdateGroupTitle
// 修改group標題
func (this *GroupService) UpdateGroupTitle(userId, groupId, title string) (ok bool) {
return db.UpdateByIdAndUserIdField(db.Groups, groupId, userId, "Title", title)
}