Erweiterung der Produktpflege

This commit is contained in:
2026-08-27 15:31:50 +02:00
parent b2ce536723
commit cdf7a538c1
240 changed files with 8264 additions and 6420 deletions
@@ -2,8 +2,8 @@ package repositories
import (
"database/sql"
"simplycpq/models"
"log"
"simplycpq/models"
)
type ProductRepository struct {
@@ -84,7 +84,7 @@ func (pr *ProductRepository) GetProductsByGroupId(groupId int) ([]*models.Produc
for rows.Next() {
product := &models.Product{}
log.Println("Scanning row into product struct") // Debugging line
log.Println("Row data:", rows) // Debugging line
log.Println("Row data:", rows) // Debugging line
err := rows.Scan(&product.ID, &product.Label, &product.ExternalID, &product.Description, &product.ProductGroupID)
if err != nil {
return nil, err
@@ -103,9 +103,11 @@ func (pr *ProductRepository) AddPropertyToProduct(productId int, propertyId int)
}
func (pr *ProductRepository) DeletePropertyFromProduct(productId int, propertyId int) error {
// Implement the logic to delete a property from a product in the database
query := "DELETE FROM product_properties WHERE productId = $1 AND propertyId = $2"
_, err := pr.dbHandler.Exec(query, productId, propertyId)
// remove the property owned by this product, including its values
if _, err := pr.dbHandler.Exec("DELETE FROM values WHERE propertyId = $1", propertyId); err != nil {
return err
}
_, err := pr.dbHandler.Exec("DELETE FROM properties WHERE productId = $1 AND id = $2", productId, propertyId)
return err
}