Exemple #1
0
func (this *AddBlogController) Post() {
	this.Ctx.Request.ParseForm()
	title := this.Ctx.Request.Form.Get("title")
	content := this.Ctx.Request.Form.Get("content")
	//打印生成日志
	defer utils.Info("addblog: ", "title:"+title, "content:"+content)
	var data models.Blogs
	data.Title = title
	data.Content = content
	//获取系统当前时间
	now := time.Now().Format("2006-01-02 15:04:05")
	data.Created = now
	models.InsertBlogs(data)
	this.Ctx.Redirect(302, "/admin/index")
}
Exemple #2
0
func (this *EditBlogController) Post() {
	this.Ctx.Request.ParseForm()
	id_str := this.Ctx.Request.Form.Get("id")
	id, _ := strconv.Atoi(id_str)
	blogInfo := models.GetBlogInfoById(id)
	title := this.Ctx.Request.Form.Get("title")
	content := this.Ctx.Request.Form.Get("content")
	blogInfo.Title = title
	blogInfo.Content = content
	//打印生成日志
	defer utils.Info("editBlog: ", "id:"+id_str, "title:"+title, "content:"+content)
	//获取系统当前时间
	now := time.Now().Format("2006-01-02 15:04:05")
	blogInfo.Created = now
	models.UpdateBlogInfo(blogInfo)
	this.Ctx.Redirect(302, "/admin/index")
}