chore: build

This commit is contained in:
2026-06-12 09:43:29 +02:00
parent 13df186854
commit 2ca28e730b
4 changed files with 79 additions and 17 deletions
+21
View File
@@ -115,6 +115,27 @@ func (d *Database) GetProductByID(id int) (models.Product, error) {
return p, nil
}
// GetProductNamesByIDs retourne un map id→name pour une liste d'IDs.
func (d *Database) GetProductNamesByIDs(ids []int) (map[int]string, error) {
result := make(map[int]string, len(ids))
if len(ids) == 0 {
return result, nil
}
rows, err := d.GDB.Raw(`SELECT id, name FROM products WHERE id IN ?`, ids).Rows()
if err != nil {
return result, err
}
defer rows.Close()
for rows.Next() {
var id int
var name string
if err := rows.Scan(&id, &name); err == nil {
result[id] = name
}
}
return result, nil
}
func (d *Database) GetAllProducts() ([]models.Product, error) {
log.Println("📦 [GetAllProducts] START")