當前位置: 首頁>>代碼示例>>Golang>>正文


Golang models.Album類代碼示例

本文整理匯總了Golang中blog/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)
}
開發者ID:gusa1120,項目名稱:beego_sample,代碼行數:8,代碼來源:photo.go

示例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)
}
開發者ID:gusa1120,項目名稱:beego_sample,代碼行數:12,代碼來源:album.go

示例3: 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.html").ToString()
	this.display("album")
}
開發者ID:gusa1120,項目名稱:beego_sample,代碼行數:18,代碼來源:main.go

示例4: 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.html", 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")
}
開發者ID:gusa1120,項目名稱:beego_sample,代碼行數:18,代碼來源:main.go

示例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()
}
開發者ID:gusa1120,項目名稱:beego_sample,代碼行數:22,代碼來源:album.go

示例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()
}
開發者ID:gusa1120,項目名稱:beego_sample,代碼行數:18,代碼來源:album.go

示例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()
}
開發者ID:gusa1120,項目名稱:beego_sample,代碼行數:17,代碼來源:album.go


注:本文中的blog/models.Album類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。