add options , config
This commit is contained in:
@@ -35,7 +35,7 @@ func GetAllAlbums(c *context.Context) {
|
||||
|
||||
// GetAlbum -
|
||||
func GetAlbum(c *context.Context) {
|
||||
id := c.Param("id")
|
||||
id := c.Param("album")
|
||||
val, ok := c.Get("token")
|
||||
if !ok {
|
||||
c.CustomRes("Foridden", "user token data not found")
|
||||
@@ -99,7 +99,7 @@ func CreateAlbum(c *context.Context) {
|
||||
|
||||
// UpdateAlbum -
|
||||
func UpdateAlbum(c *context.Context) {
|
||||
id := c.Param("id")
|
||||
id := c.Param("album")
|
||||
postData := struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
Public bool `json:"public" binding:"required"`
|
||||
@@ -146,7 +146,7 @@ func UpdateAlbum(c *context.Context) {
|
||||
|
||||
// DeleteAlbum -
|
||||
func DeleteAlbum(c *context.Context) {
|
||||
id := c.Param("id")
|
||||
id := c.Param("album")
|
||||
if len(id) == 0 {
|
||||
c.NotFound(nil)
|
||||
return
|
||||
|
||||
@@ -12,12 +12,14 @@ func GetAllAlbumPhotos(c *context.Context) {
|
||||
|
||||
// GetPhoto -
|
||||
func GetPhoto(c *context.Context) {
|
||||
album, ok := c.Get("album")
|
||||
data, ok := c.Get("album")
|
||||
album := data.(models.Album)
|
||||
if !ok {
|
||||
c.NotFound("album not found")
|
||||
return
|
||||
}
|
||||
_, err := models.GetPhoto(album.(map[string]interface{})["id"].(string))
|
||||
|
||||
_, err := models.GetPhoto(album.ID)
|
||||
if err != nil {
|
||||
c.ServerError(nil)
|
||||
return
|
||||
|
||||
@@ -51,9 +51,9 @@ func SetDefaultRoutes(r *gin.Engine) {
|
||||
albumAPI := api.Group("/album", context.PatchContext(middleware.VerifyToken))
|
||||
{
|
||||
albumAPI.POST("/", context.PatchContext(album.CreateAlbum))
|
||||
albumAPI.GET("/:id", context.PatchContext(album.GetAlbum))
|
||||
albumAPI.PUT("/:id", context.PatchContext(album.UpdateAlbum))
|
||||
albumAPI.DELETE("/:id", context.PatchContext(album.DeleteAlbum))
|
||||
albumAPI.GET("/:album", context.PatchContext(album.GetAlbum))
|
||||
albumAPI.PUT("/:album", context.PatchContext(album.UpdateAlbum))
|
||||
albumAPI.DELETE("/:album", context.PatchContext(album.DeleteAlbum))
|
||||
}
|
||||
photoAPI := albumAPI.Group("/:album/photo", context.PatchContext(middleware.VerifyToken), context.PatchContext(middleware.GetAlbumToNext))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user