Merge commit 'ed29010ba46c32663b8caa59d6ac40cc12b6d0f0' into ja
This commit is contained in:
@@ -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() {
|
func (this *ViewController) Get() {
|
||||||
inputs := this.Input()
|
id, _ := strconv.Atoi(this.Ctx.Input.Params[":id"])
|
||||||
id, _ := strconv.Atoi(this.Ctx.Params[":id"])
|
|
||||||
this.Data["Post"] = models.GetBlog(id)
|
this.Data["Post"] = models.GetBlog(id)
|
||||||
this.Layout = "layout.tpl"
|
this.Layout = "layout.tpl"
|
||||||
this.TplNames = "view.tpl"
|
this.TplNames = "view.tpl"
|
||||||
@@ -101,8 +100,7 @@ EditController
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *EditController) Get() {
|
func (this *EditController) Get() {
|
||||||
inputs := this.Input()
|
id, _ := strconv.Atoi(this.Ctx.Input.Params[":id"])
|
||||||
id, _ := strconv.Atoi(this.Ctx.Params[":id"])
|
|
||||||
this.Data["Post"] = models.GetBlog(id)
|
this.Data["Post"] = models.GetBlog(id)
|
||||||
this.Layout = "layout.tpl"
|
this.Layout = "layout.tpl"
|
||||||
this.TplNames = "new.tpl"
|
this.TplNames = "new.tpl"
|
||||||
@@ -126,8 +124,10 @@ DeleteController
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *DeleteController) Get() {
|
func (this *DeleteController) Get() {
|
||||||
id, _ := strconv.Atoi(this.Ctx.Params[":id"])
|
id, _ := strconv.Atoi(this.Ctx.Params[":id"])
|
||||||
this.Data["Post"] = models.DelBlog(id)
|
blog := GetBlog(id int)
|
||||||
|
this.Data["Post"] = blog
|
||||||
|
models.DelBlog(blog)
|
||||||
this.Ctx.Redirect(302, "/")
|
this.Ctx.Redirect(302, "/")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user