Ejemplo n.º 1
0
//设置封面
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)
}
Ejemplo n.º 2
0
Archivo: photo.go Proyecto: qiaogw/blog
//删除照片
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)
}
Ejemplo n.º 3
0
//照片列表
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()
}
Ejemplo n.º 4
0
//插入照片
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())
	}
}