From ed29010ba46c32663b8caa59d6ac40cc12b6d0f0 Mon Sep 17 00:00:00 2001 From: zerob13 Date: Thu, 13 Feb 2014 11:21:41 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B913.5=E4=B8=AD=E7=9A=84blo?= =?UTF-8?q?g=E8=8C=83=E4=BE=8B=E7=9A=84api=EF=BC=8C=E4=BB=8E=E8=80=8C?= =?UTF-8?q?=E8=83=BD=E5=9C=A8=E6=96=B0=E7=89=88beego=E4=B8=AD=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E8=BF=90=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ebook/13.5.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ebook/13.5.md b/ebook/13.5.md index 93794634..f8f80988 100644 --- a/ebook/13.5.md +++ b/ebook/13.5.md @@ -24,15 +24,15 @@ 博客主要的路由规则如下所示: //显示博客首页 - beego.RegisterController("/", &controllers.IndexController{}) + beego.Router("/", &controllers.IndexController{}) //查看博客详细信息 - beego.RegisterController("/view/:id([0-9]+)", &controllers.ViewController{}) + beego.Router("/view/:id([0-9]+)", &controllers.ViewController{}) //新建博客博文 - beego.RegisterController("/new", &controllers.NewController{}) + beego.Router("/new", &controllers.NewController{}) //删除博文 - beego.RegisterController("/delete/:id([0-9]+)", &controllers.DeleteController{}) + beego.Router("/delete/:id([0-9]+)", &controllers.DeleteController{}) //编辑博文 - beego.RegisterController("/edit/:id([0-9]+)", &controllers.EditController{}) + beego.Router("/edit/:id([0-9]+)", &controllers.EditController{}) ## 数据库结构 @@ -66,8 +66,7 @@ ViewController: } func (this *ViewController) Get() { - inputs := this.Input() - id, _ := strconv.Atoi(this.Ctx.Params[":id"]) + id, _ := strconv.Atoi(this.Ctx.Input.Params[":id"]) this.Data["Post"] = models.GetBlog(id) this.Layout = "layout.tpl" this.TplNames = "view.tpl" @@ -101,8 +100,7 @@ EditController } func (this *EditController) Get() { - inputs := this.Input() - id, _ := strconv.Atoi(this.Ctx.Params[":id"]) + id, _ := strconv.Atoi(this.Ctx.Input.Params[":id"]) this.Data["Post"] = models.GetBlog(id) this.Layout = "layout.tpl" this.TplNames = "new.tpl" @@ -126,8 +124,10 @@ DeleteController } func (this *DeleteController) Get() { - id, _ := strconv.Atoi(this.Ctx.Params[":id"]) - this.Data["Post"] = models.DelBlog(id) + id, _ := strconv.Atoi(this.Ctx.Params[":id"]) + blog := GetBlog(id int) + this.Data["Post"] = blog + models.DelBlog(blog) this.Ctx.Redirect(302, "/") } From 5b76fa228f621293f47d631c04701554d7b54d08 Mon Sep 17 00:00:00 2001 From: zerob13 Date: Thu, 13 Feb 2014 11:23:45 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B913.5=E4=B8=AD=E7=9A=84blo?= =?UTF-8?q?g=E8=8C=83=E4=BE=8B=E7=9A=84api=EF=BC=8CCtx.Input?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ebook/13.5.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebook/13.5.md b/ebook/13.5.md index f8f80988..b433d12f 100644 --- a/ebook/13.5.md +++ b/ebook/13.5.md @@ -124,7 +124,7 @@ DeleteController } func (this *DeleteController) Get() { - id, _ := strconv.Atoi(this.Ctx.Params[":id"]) + id, _ := strconv.Atoi(this.Ctx.Input.Params[":id"]) blog := GetBlog(id int) this.Data["Post"] = blog models.DelBlog(blog) From ae32378dfd1653c03b7563e85775e03400ae321a Mon Sep 17 00:00:00 2001 From: zerob13 Date: Thu, 13 Feb 2014 11:27:40 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=8C=E5=AE=8C=E5=96=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ebook/13.5.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ebook/13.5.md b/ebook/13.5.md index b433d12f..fd76d35d 100644 --- a/ebook/13.5.md +++ b/ebook/13.5.md @@ -66,7 +66,7 @@ ViewController: } func (this *ViewController) Get() { - id, _ := strconv.Atoi(this.Ctx.Input.Params[":id"]) + id, _ := strconv.Atoi(this.Ctx.Input.Params(":id")) this.Data["Post"] = models.GetBlog(id) this.Layout = "layout.tpl" this.TplNames = "view.tpl" @@ -100,7 +100,7 @@ EditController } func (this *EditController) Get() { - id, _ := strconv.Atoi(this.Ctx.Input.Params[":id"]) + id, _ := strconv.Atoi(this.Ctx.Input.Params(":id")) this.Data["Post"] = models.GetBlog(id) this.Layout = "layout.tpl" this.TplNames = "new.tpl" @@ -124,7 +124,7 @@ DeleteController } func (this *DeleteController) Get() { - id, _ := strconv.Atoi(this.Ctx.Input.Params[":id"]) + id, _ := strconv.Atoi(this.Ctx.Input.Params(":id")) blog := GetBlog(id int) this.Data["Post"] = blog models.DelBlog(blog)