update
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"git.trj.tw/golang/go-gallery/models"
|
||||
"git.trj.tw/golang/go-gallery/modules/context"
|
||||
"git.trj.tw/golang/go-gallery/modules/utils"
|
||||
)
|
||||
|
||||
// GetAlbumToNext -
|
||||
func GetAlbumToNext(c *context.Context) {
|
||||
id := c.Param("album")
|
||||
if len(id) == 0 {
|
||||
c.DataFormat("no album id")
|
||||
return
|
||||
}
|
||||
|
||||
token, ok := c.Get("token")
|
||||
if !ok {
|
||||
c.CustomRes("Foridden", nil)
|
||||
return
|
||||
}
|
||||
|
||||
album, err := models.GetAlbum(id, token.(map[string]interface{})["user"].(map[string]interface{})["id"].(string))
|
||||
if err != nil {
|
||||
c.ServerError(nil)
|
||||
return
|
||||
}
|
||||
if album == nil {
|
||||
c.NotFound("album not found")
|
||||
return
|
||||
}
|
||||
|
||||
albumMap := utils.ToMap(album)
|
||||
c.Set("album", albumMap)
|
||||
|
||||
c.Next()
|
||||
}
|
||||
Reference in New Issue
Block a user