This commit is contained in:
Jay
2018-05-25 17:26:29 +08:00
parent 59df5ce6a1
commit 70d8971e64
4 changed files with 32 additions and 5 deletions
-1
View File
@@ -52,7 +52,6 @@ func GetAlbum(c *context.Context) {
c.NotFound("album not found")
return
}
log.Println(album)
data := make(map[string]interface{})
data["album"] = utils.ToMap(album)
c.Success(data)
+28 -1
View File
@@ -9,11 +9,12 @@ import (
// GetAlbumPhotos -
func GetAlbumPhotos(c *context.Context) {
data, ok := c.Get("album")
album := data.(models.Album)
if !ok {
c.NotFound("album not found")
return
}
album := data.(*models.Album)
data = nil
photos, err := models.GetPhotos(album.ID)
if err != nil {
@@ -32,5 +33,31 @@ func GetAlbumPhotos(c *context.Context) {
// GetPhoto -
func GetPhoto(c *context.Context) {
data, ok := c.Get("album")
if !ok {
c.NotFound("album not found")
return
}
album := data.(*models.Album)
data = nil
var photoId string
photoId = c.Param("photo")
if len(photoId) == 0 {
c.DataFormat("photo id not found")
return
}
photo, err := models.GetPhoto(album.ID, photoId)
if err != nil {
c.ServerError(nil)
return
}
if photo == nil {
c.NotFound("photo not found")
return
}
res := make(map[string]interface{})
res["photo"] = utils.ToMap(photo)
c.Success(res)
}