go-gallery/routers/album/photo.go

37 lines
704 B
Go

package album
import (
"git.trj.tw/golang/go-gallery/models"
"git.trj.tw/golang/go-gallery/modules/context"
"git.trj.tw/golang/go-gallery/modules/utils"
)
// GetAlbumPhotos -
func GetAlbumPhotos(c *context.Context) {
data, ok := c.Get("album")
album := data.(models.Album)
if !ok {
c.NotFound("album not found")
return
}
photos, err := models.GetPhotos(album.ID)
if err != nil {
c.ServerError(nil)
return
}
res := make(map[string]interface{})
res["photos"] = make([]map[string]interface{}, 0)
for _, v := range photos {
res["photos"] = append(res["photos"].([]map[string]interface{}), utils.ToMap(v))
}
c.Success(res)
}
// GetPhoto -
func GetPhoto(c *context.Context) {
}