當前位置: 首頁>>代碼示例>>Golang>>正文


Golang info.Notebook類代碼示例

本文整理匯總了Golang中github.com/leanote/leanote/app/info.Notebook的典型用法代碼示例。如果您正苦於以下問題:Golang Notebook類的具體用法?Golang Notebook怎麽用?Golang Notebook使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Notebook類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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, ""
}
開發者ID:intZz,項目名稱:leanote,代碼行數:59,代碼來源:AuthService.go

示例2: AddNotebook

// 添加
// [ok]
func (this *NotebookService) AddNotebook(notebook info.Notebook) (bool, info.Notebook) {
	notebook.UrlTitle = GetUrTitle(notebook.UserId.Hex(), notebook.Title, "notebook")
	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
}
開發者ID:intZz,項目名稱:leanote,代碼行數:14,代碼來源:NotebookService.go

示例3: AddNotebook

// 添加notebook
// [OK]
func (c ApiNotebook) AddNotebook(title, parentNotebookId string, seq int) revel.Result {
	notebook := info.Notebook{NotebookId: bson.NewObjectId(),
		Title:  title,
		Seq:    seq,
		UserId: bson.ObjectIdHex(c.getUserId())}
	if parentNotebookId != "" && bson.IsObjectIdHex(parentNotebookId) {
		notebook.ParentNotebookId = bson.ObjectIdHex(parentNotebookId)
	}
	re := info.NewRe()
	re.Ok, notebook = notebookService.AddNotebook(notebook)
	if !re.Ok {
		return c.RenderJson(re)
	}
	return c.RenderJson(c.fixNotebook(&notebook))
}
開發者ID:ClaudeXin,項目名稱:leanote,代碼行數:17,代碼來源:ApiNotebookController.go

示例4: AddNotebook

// 添加notebook
func (c Notebook) AddNotebook(notebookId, title, parentNotebookId string) revel.Result {
	notebook := info.Notebook{NotebookId: bson.ObjectIdHex(notebookId),
		Title:  title,
		Seq:    -1,
		UserId: c.GetObjectUserId()}
	if parentNotebookId != "" {
		notebook.ParentNotebookId = bson.ObjectIdHex(parentNotebookId)
	}
	re := notebookService.AddNotebook(notebook)

	if re {
		return c.RenderJson(notebook)
	} else {
		return c.RenderJson(false)
	}
}
開發者ID:bigxing,項目名稱:leanote,代碼行數:17,代碼來源:NotebookController.go

示例5: AddNotebook

// 添加
// [ok]
func (this *NotebookService) AddNotebook(notebook info.Notebook) bool {
	notebook.UrlTitle = GetUrTitle(notebook.UserId.Hex(), notebook.Title, "notebook")
	err := db.Notebooks.Insert(notebook)
	if err != nil {
		panic(err)
	} else {
	}
	return true
}
開發者ID:sunyinhuiCoding,項目名稱:leanote,代碼行數:11,代碼來源:NotebookService.go

示例6: 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, ""
}
開發者ID:hello-kukoo,項目名稱:leanote,代碼行數:44,代碼來源:AuthService.go


注:本文中的github.com/leanote/leanote/app/info.Notebook類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。