// 添加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(¬ebook)) }
// 添加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) } }