chore: build

This commit is contained in:
2026-06-11 19:04:04 +02:00
parent a1d5664d6b
commit b5196c5f22
2 changed files with 10 additions and 11 deletions
+4 -4
View File
@@ -182,12 +182,12 @@ func (d *Database) GetProductsByCategory(category string) ([]models.Product, err
return products, nil return products, nil
} }
func (d *Database) UpdateProduct(productID int, name, category, description, unit string, prices []models.ProductPrice) error { func (d *Database) UpdateProduct(productID int, name, category, description, unit string, comingSoon bool, prices []models.ProductPrice) error {
err := d.GDB.Exec(` err := d.GDB.Exec(`
UPDATE products UPDATE products
SET name = ?, category = ?, description = ?, unit = ?, updated_at = ? SET name = ?, category = ?, description = ?, unit = ?, coming_soon = ?, updated_at = ?
WHERE id = ?`, WHERE id = ?`,
name, category, description, unit, time.Now(), productID).Error name, category, description, unit, comingSoon, time.Now(), productID).Error
if err != nil { if err != nil {
return fmt.Errorf("erreur mise à jour produit: %w", err) return fmt.Errorf("erreur mise à jour produit: %w", err)
} }
@@ -197,7 +197,7 @@ func (d *Database) UpdateProduct(productID int, name, category, description, uni
for _, price := range prices { for _, price := range prices {
if err := d.GDB.Exec(`INSERT INTO product_prices (product_id, quantity, price, active_price) VALUES (?, ?, ?, ?)`, if err := d.GDB.Exec(`INSERT INTO product_prices (product_id, quantity, price, active_price) VALUES (?, ?, ?, ?)`,
productID, price.Quantity, price.Price, price.ActivePrice).Error; err != nil { productID, price.Quantity, price.Price, price.ActivePrice).Error; err != nil {
log.Printf("❌ [UpdateProduct] Erreur prix: %v", err) return fmt.Errorf("erreur insertion prix: %w", err)
} }
} }
+6 -7
View File
@@ -635,7 +635,12 @@ func UpdateProduct(c *gin.Context) {
log.Printf("🔄 [UpdateProduct] %s met à jour produit #%d", username, id) log.Printf("🔄 [UpdateProduct] %s met à jour produit #%d", username, id)
if err := database.UpdateProduct(id, updateData.Name, updateData.Category, updateData.Description, updateData.Unit, updateData.Prices); err != nil { comingSoon := false
if updateData.ComingSoon != nil {
comingSoon = *updateData.ComingSoon
}
if err := database.UpdateProduct(id, updateData.Name, updateData.Category, updateData.Description, updateData.Unit, comingSoon, updateData.Prices); err != nil {
log.Printf("❌ [UpdateProduct] Erreur UPDATE: %v", err) log.Printf("❌ [UpdateProduct] Erreur UPDATE: %v", err)
c.JSON(http.StatusInternalServerError, gin.H{"error": "Erreur mise à jour"}) c.JSON(http.StatusInternalServerError, gin.H{"error": "Erreur mise à jour"})
return return
@@ -647,12 +652,6 @@ func UpdateProduct(c *gin.Context) {
} }
} }
if updateData.ComingSoon != nil {
if err := database.SetProductComingSoon(id, *updateData.ComingSoon); err != nil {
log.Printf("⚠️ [UpdateProduct] Erreur mise à jour coming_soon: %v", err)
}
}
// ✅ RÉCUPÉRER LE PRODUIT MIS À JOUR // ✅ RÉCUPÉRER LE PRODUIT MIS À JOUR
updatedProduct, _ := database.GetProductByID(id) updatedProduct, _ := database.GetProductByID(id)
media, _ := database.GetMediaByProductID(id) media, _ := database.GetMediaByProductID(id)