chore: build
Backend - Build & Lint / build (push) Has been cancelled

This commit is contained in:
2026-07-01 20:56:41 +02:00
parent 9e6473ed3f
commit cfb5b79025
6 changed files with 54 additions and 25 deletions
+14
View File
@@ -174,6 +174,20 @@ func (d *Database) GetMediaByID(mediaID int) (*models.Media, error) {
return &media, nil
}
// GetMediaBatch charge les médias de plusieurs produits en une seule requête.
func (d *Database) GetMediaBatch(productIDs []int) map[int][]models.Media {
result := make(map[int][]models.Media, len(productIDs))
if len(productIDs) == 0 {
return result
}
var mediaList []models.Media
d.GDB.Raw(`SELECT id, product_id, url, type, key, created_at FROM media WHERE product_id IN ? ORDER BY product_id ASC, id ASC`, productIDs).Scan(&mediaList)
for _, m := range mediaList {
result[m.ProductID] = append(result[m.ProductID], m)
}
return result
}
func (d *Database) GetMediaByProductID(productID int) ([]models.Media, error) {
log.Printf("🖼️ [GetMediaByProductID] START - ProductID=%d", productID)