Browse Source

blogcontroller

layui
aarone 6 years ago
parent
commit
8dce9cb263
  1. 9
      controllers/BlogController.go

9
controllers/BlogController.go

@ -1,9 +1,9 @@
package controllers package controllers
import ( import (
"github.com/astaxie/beego"
"beeblog/models" "beeblog/models"
"beeblog/service" "beeblog/service"
"github.com/astaxie/beego"
"strconv" "strconv"
) )
@ -19,7 +19,7 @@ func (this *BlogController) Save() {
labels := this.GetStrings("labels[]") labels := this.GetStrings("labels[]")
blog := &models.Blog{Title: title, BlogHtml: blogHtml, CategoryId: catoryId, UserId: 1} blog := &models.Blog{Title: title, BlogHtml: blogHtml, CategoryId: catoryId, UserId: 1}
err := service.SaveBlog(blog, labels) err := service.SaveBlog(blog, labels)
if (err == nil) { if err == nil {
this.Data["json"] = blog this.Data["json"] = blog
} else { } else {
this.Data["json"] = models.ReurnError("保存失败") this.Data["json"] = models.ReurnError("保存失败")
@ -31,7 +31,7 @@ func (this *BlogController) Get() {
idStr := this.Ctx.Input.Param(":id") idStr := this.Ctx.Input.Param(":id")
id, _ := strconv.ParseInt(idStr, 10, 64) id, _ := strconv.ParseInt(idStr, 10, 64)
blog, err := service.GetBlog(id) blog, err := service.GetBlog(id)
if (err == nil) { if err == nil {
this.Data["Blog"] = blog this.Data["Blog"] = blog
} }
this.TplName = "blog.html" this.TplName = "blog.html"
@ -40,3 +40,6 @@ func (this *BlogController) Get() {
func (this *BlogController) New() { func (this *BlogController) New() {
this.TplName = "newblog.html" this.TplName = "newblog.html"
} }
func (this *BlogController) Blog1() {
this.TplName = "blog1.html"
}

Loading…
Cancel
Save