diff --git a/controllers/BlogController.go b/controllers/BlogController.go index 8b4f6ba..7d97cf4 100644 --- a/controllers/BlogController.go +++ b/controllers/BlogController.go @@ -1,9 +1,9 @@ package controllers import ( - "github.com/astaxie/beego" "beeblog/models" "beeblog/service" + "github.com/astaxie/beego" "strconv" ) @@ -19,7 +19,7 @@ func (this *BlogController) Save() { labels := this.GetStrings("labels[]") blog := &models.Blog{Title: title, BlogHtml: blogHtml, CategoryId: catoryId, UserId: 1} err := service.SaveBlog(blog, labels) - if (err == nil) { + if err == nil { this.Data["json"] = blog } else { this.Data["json"] = models.ReurnError("保存失败") @@ -31,7 +31,7 @@ func (this *BlogController) Get() { idStr := this.Ctx.Input.Param(":id") id, _ := strconv.ParseInt(idStr, 10, 64) blog, err := service.GetBlog(id) - if (err == nil) { + if err == nil { this.Data["Blog"] = blog } this.TplName = "blog.html" @@ -40,3 +40,6 @@ func (this *BlogController) Get() { func (this *BlogController) New() { this.TplName = "newblog.html" } +func (this *BlogController) Blog1() { + this.TplName = "blog1.html" +} diff --git a/routers/BlogRouter.go b/routers/BlogRouter.go index e927475..7fcf040 100644 --- a/routers/BlogRouter.go +++ b/routers/BlogRouter.go @@ -1,12 +1,13 @@ package routers import ( - "github.com/astaxie/beego" "beeblog/controllers" + "github.com/astaxie/beego" ) func init() { beego.Router("/blog/new", &controllers.BlogController{}, "post:Save") beego.Router("/blog/:id([0-9]+)", &controllers.BlogController{}, "get:Get") beego.Router("/blog/new", &controllers.BlogController{}, "get:New") + beego.Router("/blog1", &controllers.BlogController{}, "get:Blog1") } diff --git a/routers/UserRouter.go b/routers/UserRouter.go index 5bf1dd6..6cb5b14 100644 --- a/routers/UserRouter.go +++ b/routers/UserRouter.go @@ -1,8 +1,8 @@ package routers import ( - "github.com/astaxie/beego" "beeblog/controllers" + "github.com/astaxie/beego" ) func init() { diff --git a/views/blog1.html b/views/blog1.html new file mode 100644 index 0000000..8fc470d --- /dev/null +++ b/views/blog1.html @@ -0,0 +1,59 @@ +{{template "header"}} +
+ ++
+ ++
+ ++
+ ++