本文整理汇总了Golang中github.com/jxufeliujj/blog/models.Photo类的典型用法代码示例。如果您正苦于以下问题:Golang Photo类的具体用法?Golang Photo怎么用?Golang Photo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Photo类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Cover
//设置封面
func (this *PhotoController) Cover() {
id, _ := this.GetInt("id")
photo := models.Photo{Id: id}
if photo.Read() == nil {
photo.Delete()
}
this.Redirect("/admin/photo/list", 302)
}
示例2: Delete
//删除照片
func (this *PhotoController) Delete() {
id, _ := this.GetInt64("id")
albumid := this.GetString("albumid")
photo := models.Photo{Id: id}
if photo.Read() == nil {
photo.Delete()
}
this.Redirect("/admin/photo/list?albumid="+albumid, 302)
}
示例3: List
//照片列表
func (this *PhotoController) List() {
var albumid int64
var list []*models.Photo
var photo models.Photo
if albumid, _ = this.GetInt("albumid"); albumid < 1 {
albumid = 1
}
photo.Query().Filter("albumid", albumid).OrderBy("-posttime").All(&list)
for _, v := range list {
v.Small = strings.Replace(v.Url, "bigpic", "smallpic", 1)
}
this.Data["list"] = list
this.Data["albumid"] = albumid
this.display()
}
示例4: Insert
//插入照片
func (this *PhotoController) Insert(albumid int64, desc, url string) {
var photo models.Photo
photo.Albumid = albumid
photo.Des = desc
photo.Posttime = time.Now()
photo.Url = url
if err := photo.Insert(); err != nil {
this.showmsg(err.Error())
}
}