diff --git a/controllers/NoteController.go b/controllers/NoteController.go index 3fd582a..50c0efc 100644 --- a/controllers/NoteController.go +++ b/controllers/NoteController.go @@ -1,10 +1,10 @@ package controllers import ( - "github.com/astaxie/beego" - "strconv" "beeblog/models" "beeblog/service" + "github.com/astaxie/beego" + "strconv" ) type NoteController struct { @@ -16,12 +16,14 @@ func (this *NoteController) Save() { pid, _ := this.GetInt64("pid") title := this.GetString("title") uid := this.GetSession("userid") + noteHtml := this.GetString("noteHtml") + noteVal := this.GetString("noteVal") if uid == nil { this.Data["json"] = models.ReurnError(401, "保存失败") this.ServeJSON() return } - note := &models.Note{Title: title, Pid: pid, UserId: uid.(int64)} + note := &models.Note{Title: title, Pid: pid, UserId: uid.(int64), NoteVal: noteVal, NoteHtml: noteHtml} err := noteService.SaveNote(note) if err == nil { this.Data["json"] = note @@ -35,6 +37,7 @@ func (this *NoteController) Edit() { noteService := service.NoteService{} idStr := this.Ctx.Input.Param(":id") noteHtml := this.GetString("noteHtml") + noteVal := this.GetString("noteVal") id, _ := strconv.ParseInt(idStr, 10, 64) uid := this.GetSession("userid") if uid == nil { @@ -55,6 +58,7 @@ func (this *NoteController) Edit() { return } note.NoteHtml = noteHtml + note.NoteVal = noteVal err := noteService.EditNote(note) if err == nil { this.Data["json"] = models.ReurnSuccess("") @@ -77,7 +81,7 @@ func (this *NoteController) SaveNoteColl() { note := &models.NoteColl{Title: title, UserId: uid.(int64)} err := noteService.SaveNoteColl(note) if err == nil { - this.Data["json"] = models.ReurnData("",note) + this.Data["json"] = models.ReurnData("", note) } else { this.Data["json"] = models.ReurnError(500, "保存失败") } @@ -229,4 +233,4 @@ func (this *NoteController) NoteApi() { } this.Data["json"] = noteColls this.ServeJSON() -} \ No newline at end of file +} diff --git a/routers/NoteRouter.go b/routers/NoteRouter.go index 231056b..887accc 100644 --- a/routers/NoteRouter.go +++ b/routers/NoteRouter.go @@ -8,7 +8,7 @@ import ( func init() { beego.Router("/api/note/:id([0-9]+)", &controllers.NoteController{}, "get:Get") beego.Router("/note", &controllers.NoteController{}, "get:Note") - beego.Router("/note/api", &controllers.NoteController{}, "get:NoteApi") + beego.Router("/api/note", &controllers.NoteController{}, "get:NoteApi") beego.Router("/api/notecoll/save", &controllers.NoteController{}, "post:SaveNoteColl") beego.Router("/api/notecoll/edit", &controllers.NoteController{}, "post:EditNoteColl") beego.Router("/api/note/save", &controllers.NoteController{}, "post:Save") diff --git a/views/note.html b/views/note.html index a443fc6..8cdf821 100644 --- a/views/note.html +++ b/views/note.html @@ -62,7 +62,23 @@
-