コード例 #1
0
// 添加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))
}
コード例 #2
0
ファイル: NotebookController.go プロジェクト: nosqldb/zhujian
// 添加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, notebook := notebookService.AddNotebook(notebook)

	if re {
		return c.RenderJson(notebook)
	} else {
		return c.RenderJson(false)
	}
}