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


Golang Dbh.GetAlbumByName方法代碼示例

本文整理匯總了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)
}
開發者ID:szwork2013,項目名稱:gopixelrelay,代碼行數:37,代碼來源:album.go

示例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)
}
開發者ID:szwork2013,項目名稱:gopixelrelay,代碼行數:24,代碼來源:albumdelete.go


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