本文整理匯總了Golang中github.com/jxufeliujj/blog/models.Mood類的典型用法代碼示例。如果您正苦於以下問題:Golang Mood類的具體用法?Golang Mood怎麽用?Golang Mood使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Mood類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Delete
//刪除說說
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)
}
示例2: Mood
//說說
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")
}
示例3: List
//說說列表
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()
}
示例4: Add
//發表說說
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()
}