Exemple #1
0
//删除说说
func (this *MoodController) Delete() {
	id, _ := this.GetInt("id")
	mood := models.Mood{Id: id}
	if mood.Read() == nil {
		mood.Delete()
	}
	this.Redirect("/admin/mood/list", 302)
}
Exemple #2
0
//说说
func (this *MainController) Mood() {
	var list []*models.Mood
	query := new(models.Mood).Query()
	count, _ := query.Count()
	if count > 0 {
		query.OrderBy("-posttime").Limit(this.pagesize, (this.page-1)*this.pagesize).All(&list)
	}
	this.Data["list"] = list
	this.setHeadMetas("碎言碎语")
	this.right = ""
	this.Data["pagebar"] = models.NewPager(int64(this.page), int64(count), int64(this.pagesize), "/mood%d.html").ToString()
	this.display("mood")
}
Exemple #3
0
//说说列表
func (this *MoodController) List() {
	var page int64
	var pagesize int64 = 10
	var list []*models.Mood
	var mood models.Mood

	if page, _ = this.GetInt("page"); page < 1 {
		page = 1
	}
	offset := (page - 1) * pagesize

	count, _ := mood.Query().Count()
	if count > 0 {
		mood.Query().OrderBy("-id").Limit(pagesize, offset).All(&list)
	}

	this.Data["list"] = list
	this.Data["pagebar"] = models.NewPager(page, count, pagesize, "/admin/mood/list?page=%d").ToString()
	this.display()
}
Exemple #4
0
//发表说说
func (this *MoodController) Add() {
	if this.Ctx.Request.Method == "POST" {
		content := strings.TrimSpace(this.GetString("content"))
		cover := strings.TrimSpace(this.GetString("cover"))

		var mood models.Mood
		mood.Content = content
		mood.Cover = cover
		mood.Posttime = time.Now()
		if err := mood.Insert(); err != nil {
			this.showmsg(err.Error())
		}
		this.Redirect("/admin/mood/list", 302)

	}
	this.display()
}