update
This commit is contained in:
		
							parent
							
								
									fe884e6931
								
							
						
					
					
						commit
						59df5ce6a1
					
				| @ -3,15 +3,11 @@ package album | |||||||
| import ( | import ( | ||||||
| 	"git.trj.tw/golang/go-gallery/models" | 	"git.trj.tw/golang/go-gallery/models" | ||||||
| 	"git.trj.tw/golang/go-gallery/modules/context" | 	"git.trj.tw/golang/go-gallery/modules/context" | ||||||
|  | 	"git.trj.tw/golang/go-gallery/modules/utils" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // GetAllAlbumPhotos - | // GetAlbumPhotos - | ||||||
| func GetAllAlbumPhotos(c *context.Context) { | func GetAlbumPhotos(c *context.Context) { | ||||||
| 
 |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| // GetPhoto - |  | ||||||
| func GetPhoto(c *context.Context) { |  | ||||||
| 	data, ok := c.Get("album") | 	data, ok := c.Get("album") | ||||||
| 	album := data.(models.Album) | 	album := data.(models.Album) | ||||||
| 	if !ok { | 	if !ok { | ||||||
| @ -19,9 +15,22 @@ func GetPhoto(c *context.Context) { | |||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	_, err := models.GetPhoto(album.ID) | 	photos, err := models.GetPhotos(album.ID) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		c.ServerError(nil) | 		c.ServerError(nil) | ||||||
| 		return | 		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) { | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -57,6 +57,6 @@ func SetDefaultRoutes(r *gin.Engine) { | |||||||
| 	} | 	} | ||||||
| 	photoAPI := albumAPI.Group("/:album/photo", context.PatchContext(middleware.VerifyToken), context.PatchContext(middleware.GetAlbumToNext)) | 	photoAPI := albumAPI.Group("/:album/photo", context.PatchContext(middleware.VerifyToken), context.PatchContext(middleware.GetAlbumToNext)) | ||||||
| 	{ | 	{ | ||||||
| 		photoAPI.GET("/", context.PatchContext(album.GetPhoto)) | 		photoAPI.GET("/", context.PatchContext(album.GetAlbumPhotos)) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user