Ejemplo n.º 1
0
func (this *NewController) Post() {
	inputs := this.Input()
	var blog models.Entity
	blog.Title = inputs.Get("title")
	blog.Content = inputs.Get("content")
	blog.Created = time.Now()
	logs.Logger.Info("blog:", blog)
	models.SaveBlog(blog)
	this.Ctx.Redirect(302, "/")
}
Ejemplo n.º 2
0
func (this *EditController) Post() {
	inputs := this.Input()
	var blog models.Entity
	logs.Logger.Info("inputs:", inputs)
	blog.Id, _ = strconv.Atoi(inputs.Get("id"))
	blog.Title = inputs.Get("title")
	blog.Content = inputs.Get("content")
	dataStr := inputs.Get("created")
	date, err := time.Parse("2006-01-02 15:04:05", dataStr)
	if err != nil {
		logs.Logger.Warn("time parse error:", dataStr)
		date = time.Now()
	}
	blog.Created = date
	models.UpdateBlog(blog)
	this.Ctx.Redirect(302, "/")
}