//添加 func (this *ArticleController) Add() { var list []*models.Tag var tag models.Tag var day = this.GetString("d") var month = this.GetString("m") tag.Query().OrderBy("-count").All(&list) this.Data["list"] = list this.Data["day"] = day this.Data["month"] = month this.display() }
//编辑 func (this *ArticleController) Edit() { var ( list []*models.Tag tag models.Tag ) id, _ := this.GetInt64("id") post := models.Article{Id: id} if post.Read() != nil { this.Abort("404") } tag.Query().OrderBy("-count").All(&list) fmt.Println(list) this.Data["list"] = list this.Data["post"] = post this.display() }
//标签列表 func (this *TagController) List() { var page int var pagesize int = 10 var list []*models.Tag var tag models.Tag if page, _ = this.GetInt("page"); page < 1 { page = 1 } offset := (page - 1) * pagesize count, _ := tag.Query().Count() if count > 0 { tag.Query().OrderBy("-count").Limit(pagesize, offset).All(&list) } this.Data["count"] = count this.Data["list"] = list this.Data["pagebar"] = util.NewPager(page, int(count), pagesize, "/admin/tag", true).ToString() this.display("tag/list") }