本文整理汇总了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()
}