码农笔录博客源码
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

43 行
957 B

package controllers
import (
"github.com/astaxie/beego"
"beeblog/models"
"beeblog/service"
"strconv"
)
type BlogController struct {
beego.Controller
}
func (this *BlogController) Save() {
6 年前
title := this.GetString("title")
blogHtml := this.GetString("blogHtml")
catory := this.GetString("catory")
catoryId, _ := strconv.ParseInt(catory, 10, 64)
labels := this.GetStrings("labels[]")
6 年前
blog := &models.Blog{Title: title, BlogHtml: blogHtml, CategoryId: catoryId, UserId: 1}
err := service.SaveBlog(blog, labels)
if (err == nil) {
this.Data["json"] = blog
} else {
this.Data["json"] = models.ReurnError("保存失败")
}
this.ServeJSON()
}
func (this *BlogController) Get() {
idStr := this.Ctx.Input.Param(":id")
id, _ := strconv.ParseInt(idStr, 10, 64)
blog, err := service.GetBlog(id)
if (err == nil) {
this.Data["Blog"] = blog
}
this.TplName = "blog.html"
}
6 年前
func (this *BlogController) New() {
this.TplName = "newblog.html"
6 年前
}