本文整理汇总了Golang中pixelrelay/db.Dbh.GetAlbumByName方法的典型用法代码示例。如果您正苦于以下问题:Golang Dbh.GetAlbumByName方法的具体用法?Golang Dbh.GetAlbumByName怎么用?Golang Dbh.GetAlbumByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pixelrelay/db.Dbh
的用法示例。
在下文中一共展示了Dbh.GetAlbumByName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Album
func Album(args martini.Params, su models.User, session sessions.Session, r render.Render, dbh *db.Dbh, p *models.Page) {
name := args["name"]
auser := args["user"]
key := args["key"]
if auser != "" {
log.Println("album user: ", auser)
}
album := dbh.GetAlbumByName(name)
if su.Id != album.User && album.Private && album.Privatekey != key {
session.Set("flash", "Login Required")
r.Redirect(strings.Join([]string{utils.AppCfg.Url(), "login"}, "/"), http.StatusFound)
return
}
images := dbh.GetAllImagesByAlbumId(album.Id)
var imageLinks []imageLink
for _, f := range images {
if f.Trashed {
continue
}
var file_name = f.Name
if f.HashId != "" {
file_name = f.HashId
}
log.Println(file_name, f)
imageLinks = append(imageLinks, imageLink{Id: f.Id, Title: f.Name, FileName: file_name, Owner: f.User})
}
p.SetTitle("Album", name)
p.SetUser(su)
p.Data = AlbumVars{Title: name, Description: album.Description, ImageLinks: imageLinks}
encoder.Render(p.Encoding, 200, "image_link", p, r)
}
示例2: AlbumDelete
func AlbumDelete(args martini.Params, req *http.Request, r render.Render, su models.User, dbh *db.Dbh, p *models.Page) {
// Default status
var result string = "Not Deleted"
var status string = "Permission Denied"
var code int = 401
name := args["name"]
album := dbh.GetAlbumByName(name)
if album.User == su.Id {
status = "Success"
result = "Deleted"
dAlbum := dbh.AlbumDelete(album)
log.Printf("%+v", dAlbum)
}
if album.Id == 0 {
status = "Album not found"
code = 404
}
p.Data = models.AlbumResult{Name: name, Result: result, Status: status}
log.Println("Album Delete: User: ", su.Id, " Album: ", name, " Result: ", result, " Status: ", status)
encoder.Render("json", code, "", p, r)
}