本文整理汇总了Golang中github.com/jerusalemdax/Mona/models.Album类的典型用法代码示例。如果您正苦于以下问题:Golang Album类的具体用法?Golang Album怎么用?Golang Album使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Album类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Cover
//设置封面
func (this *PhotoController) Cover() {
id, _ := this.GetInt64("albumid")
cover := this.GetString("cover")
album := models.Album{Id: id, Cover: cover}
album.Update("cover")
this.Redirect("/admin/album/list", 302)
}
示例2: Delete
//删除相册
func (this *AlbumController) Delete() {
id, _ := this.GetInt64("albumid")
album := models.Album{Id: id}
h, _ := strconv.Atoi(this.GetString("ishide"))
album.Ishide = int8(h)
if err := album.Update("ishide"); err != nil {
this.showmsg(err.Error())
return
}
this.Redirect("/admin/album/list", 302)
}
示例3: Photo
//照片展示
func (this *MainController) Photo() {
album := new(models.Album)
album.Id = int64(this.page)
err := album.Read()
if err != nil || album.Ishide != 0 {
this.Redirect("/404", 302)
}
this.setHeadMetas("相册 " + album.Name + " 内的照片")
var list []*models.Photo
new(models.Photo).Query().Filter("albumid", this.page).All(&list)
this.right = ""
for _, v := range list {
v.Small = strings.Replace(v.Url, "bigpic", "smallpic", 1)
}
this.Data["list"] = list
this.display("photo")
}
示例4: Album
func (this *MainController) Album() {
pagesize, _ := strconv.Atoi(this.getOption("albumsize"))
if pagesize < 1 {
pagesize = 12
}
var list []*models.Album
query := new(models.Album).Query().Filter("ishide", 0)
count, _ := query.Count()
if count > 0 {
query.OrderBy("-rank", "-posttime").Limit(pagesize, (this.page-1)*pagesize).All(&list)
}
this.setHeadMetas("美丽瞬间")
this.right = ""
this.Data["list"] = list
this.Data["pagebar"] = models.NewPager(int64(this.page), int64(count), int64(pagesize), "/album/%d").ToString()
this.display("album")
}
示例5: List
//相册列表
func (this *AlbumController) List() {
var page int64
var pagesize int64 = 6
var list []*models.Album
var album models.Album
if page, _ = this.GetInt64("page"); page < 1 {
page = 1
}
offset := (page - 1) * pagesize
query := album.Query()
count, _ := query.Count()
if count > 0 {
query.OrderBy("-rank", "-posttime").Limit(pagesize, offset).All(&list)
}
this.Data["list"] = list
this.Data["pagebar"] = models.NewPager(page, count, pagesize, "/admin/album/list?page=%d").ToString()
this.display()
}
示例6: Edit
//修改
func (this *AlbumController) Edit() {
id, _ := this.GetInt64("albumid")
album := models.Album{Id: id}
if album.Read() != nil {
this.Abort("404")
}
if this.Ctx.Request.Method == "POST" {
rank, _ := this.GetInt("rank")
album.Cover = this.GetString("cover")
album.Name = this.GetString("albumname")
album.Rank = int8(rank)
album.Update()
this.Redirect("/admin/album/list", 302)
}
this.Data["album"] = album
this.display()
}
示例7: Add
//创建相册
func (this *AlbumController) Add() {
if this.Ctx.Request.Method == "POST" {
rank, _ := this.GetInt("rank")
var album models.Album
album.Name = strings.TrimSpace(this.GetString("albumname"))
album.Cover = strings.TrimSpace(this.GetString("cover"))
album.Rank = int8(rank)
album.Posttime = time.Now()
if err := album.Insert(); err != nil {
this.showmsg(err.Error())
}
this.Redirect("/admin/album/list", 302)
}
this.display()
}