本文整理匯總了Golang中github.com/leanote/leanote/app/info.Notebook.NotebookId方法的典型用法代碼示例。如果您正苦於以下問題:Golang Notebook.NotebookId方法的具體用法?Golang Notebook.NotebookId怎麽用?Golang Notebook.NotebookId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/leanote/leanote/app/info.Notebook
的用法示例。
在下文中一共展示了Notebook.NotebookId方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: register
func (this *AuthService) register(user info.User) (bool, string) {
if userService.AddUser(user) {
// 添加筆記本, 生活, 學習, 工作
userId := user.UserId.Hex()
notebook := info.Notebook{
Seq: -1,
UserId: user.UserId}
title2Id := map[string]bson.ObjectId{"life": bson.NewObjectId(), "study": bson.NewObjectId(), "work": bson.NewObjectId()}
for title, objectId := range title2Id {
notebook.Title = title
notebook.NotebookId = objectId
notebook.UserId = user.UserId
notebookService.AddNotebook(notebook)
}
// 添加leanote -> 該用戶的共享
registerSharedUserId := configService.GetGlobalStringConfig("registerSharedUserId")
if registerSharedUserId != "" {
registerSharedNotebooks := configService.GetGlobalArrMapConfig("registerSharedNotebooks")
registerSharedNotes := configService.GetGlobalArrMapConfig("registerSharedNotes")
registerCopyNoteIds := configService.GetGlobalArrayConfig("registerCopyNoteIds")
// 添加共享筆記本
for _, notebook := range registerSharedNotebooks {
perm, _ := strconv.Atoi(notebook["perm"])
shareService.AddShareNotebookToUserId(notebook["notebookId"], perm, registerSharedUserId, userId)
}
// 添加共享筆記
for _, note := range registerSharedNotes {
perm, _ := strconv.Atoi(note["perm"])
shareService.AddShareNoteToUserId(note["noteId"], perm, registerSharedUserId, userId)
}
// 複製筆記
for _, noteId := range registerCopyNoteIds {
note := noteService.CopySharedNote(noteId, title2Id["life"].Hex(), registerSharedUserId, user.UserId.Hex())
// Log(noteId)
// Log("Copy")
// LogJ(note)
noteUpdate := bson.M{"IsBlog": false} // 不要是博客
noteService.UpdateNote(user.UserId.Hex(), note.NoteId.Hex(), noteUpdate, -1)
}
}
//---------------
// 添加一條userBlog
blogService.UpdateUserBlog(info.UserBlog{UserId: user.UserId,
Title: user.Username + " 's Blog",
SubTitle: "Love Leanote!",
AboutMe: "Hello, I am (^_^)",
CanComment: true,
})
// 添加一個單頁麵
blogService.AddOrUpdateSingle(user.UserId.Hex(), "", "About Me", "Hello, I am (^_^)")
}
return true, ""
}
示例2: AddNotebook
// 添加
func (this *NotebookService) AddNotebook(notebook info.Notebook) (bool, info.Notebook) {
if notebook.NotebookId == "" {
notebook.NotebookId = bson.NewObjectId()
}
notebook.UrlTitle = GetUrTitle(notebook.UserId.Hex(), notebook.Title, "notebook", notebook.NotebookId.Hex())
notebook.Usn = userService.IncrUsn(notebook.UserId.Hex())
now := time.Now()
notebook.CreatedTime = now
notebook.UpdatedTime = now
err := db.Notebooks.Insert(notebook)
if err != nil {
return false, notebook
}
return true, notebook
}
示例3: register
func (this *AuthService) register(user info.User) (bool, string) {
if userService.AddUser(user) {
// 添加筆記本, 生活, 學習, 工作
notebook := info.Notebook{
Seq: -1,
UserId: user.UserId}
title2Id := map[string]bson.ObjectId{"life": bson.NewObjectId(), "study": bson.NewObjectId(), "work": bson.NewObjectId()}
for title, objectId := range title2Id {
notebook.Title = title
notebook.NotebookId = objectId
notebook.UserId = user.UserId
notebookService.AddNotebook(notebook)
}
email := user.Email
// 添加leanote -> 該用戶的共享
leanoteUserId, _ := revel.Config.String("register.sharedUserId") // "5368c1aa99c37b029d000001";
nk1, _ := revel.Config.String("register.sharedUserShareNotebookId") // 5368c1aa99c37b029d000002" // leanote
welcomeNoteId, _ := revel.Config.String("register.welcomeNoteId") // "5368c1b919807a6f95000000" // 歡迎來到leanote
if leanoteUserId != "" && nk1 != "" && welcomeNoteId != "" {
shareService.AddShareNotebook(nk1, 0, leanoteUserId, email)
shareService.AddShareNote(welcomeNoteId, 0, leanoteUserId, email)
// 將welcome copy給我
note := noteService.CopySharedNote(welcomeNoteId, title2Id["life"].Hex(), leanoteUserId, user.UserId.Hex())
// 公開為博客
noteUpdate := bson.M{"IsBlog": true}
noteService.UpdateNote(user.UserId.Hex(), user.UserId.Hex(), note.NoteId.Hex(), noteUpdate)
}
//---------------
// 添加一條userBlog
blogService.UpdateUserBlog(info.UserBlog{UserId: user.UserId,
Title: user.Username + " 's Blog",
SubTitle: "love leanote!",
AboutMe: "Hello, I am (^_^)",
})
}
return true, ""
}