From ed29010ba46c32663b8caa59d6ac40cc12b6d0f0 Mon Sep 17 00:00:00 2001 From: zerob13 Date: Thu, 13 Feb 2014 11:21:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B913.5=E4=B8=AD=E7=9A=84blog?= =?UTF-8?q?=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, "/") }