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, "/") }