This commit is contained in:
2026-08-16 19:49:34 +02:00
parent 5060fe5a2e
commit 989cda7036
4 changed files with 19 additions and 19 deletions
@@ -19,7 +19,7 @@ func NewProductGroupRepository(db *sql.DB, valueRepository *ValueRepository) *Pr
func (r *ProductGroupRepository) CreateProductGroup(productGroup *models.ProductGroup) (*models.ProductGroup, error) {
// Insert the product group into the database
query := "INSERT INTO product_groups (label, description, parentgroupid) VALUES($1,$2,$3) RETURNING id"
query := "INSERT INTO productgroups (label, description, parentgroupid) VALUES($1,$2,$3) RETURNING id"
err := r.db.QueryRow(query, productGroup.Label, productGroup.Description, productGroup.ParentGroupID).Scan(&productGroup.ID)
if err != nil {
return nil, err
@@ -42,7 +42,7 @@ func (r *ProductGroupRepository) CreateProductGroup(productGroup *models.Product
}
func (r *ProductGroupRepository) UpdateProductGroup(productGroup *models.ProductGroup) (*models.ProductGroup, error) {
query := "UPDATE product_groups SET label=$1, description=$2, parentgroupid=$3 WHERE id=$4"
query := "UPDATE productgroups SET label=$1, description=$2, parentgroupid=$3 WHERE id=$4"
_, err := r.db.Exec(query, productGroup.Label, productGroup.Description, productGroup.ParentGroupID, productGroup.ID)
if err != nil {
return nil, err
@@ -51,7 +51,7 @@ func (r *ProductGroupRepository) UpdateProductGroup(productGroup *models.Product
}
func (r *ProductGroupRepository) DeleteProductGroup(id int) error {
query := "DELETE FROM product_groups WHERE id=$1"
query := "DELETE FROM productgroups WHERE id=$1"
_, err := r.db.Exec(query, id)
if err != nil {
return err
@@ -60,7 +60,7 @@ func (r *ProductGroupRepository) DeleteProductGroup(id int) error {
}
func (r *ProductGroupRepository) GetProductGroup(id int) (*models.ProductGroup, error) {
query := "SELECT id, label, description, parentgroupid FROM product_groups WHERE id=$1"
query := "SELECT id, label, description, parentgroupid FROM productgroups WHERE id=$1"
row := r.db.QueryRow(query, id)
productGroup := &models.ProductGroup{}
err := row.Scan(&productGroup.ID, &productGroup.Label, &productGroup.Description, &productGroup.ParentGroupID)
@@ -71,7 +71,7 @@ func (r *ProductGroupRepository) GetProductGroup(id int) (*models.ProductGroup,
}
func (r *ProductGroupRepository) GetProductGroupsByParentId(parentId int) ([]*models.ProductGroup, error) {
query := "SELECT id, label, description, parentgroupid FROM product_groups WHERE parentgroupid=$1"
query := "SELECT id, label, description, parentgroupid FROM productgroups WHERE parentgroupid=$1"
rows, err := r.db.Query(query, parentId)
if err != nil {
return nil, err
@@ -149,4 +149,4 @@ func (r *ProductGroupRepository) CreatePropertyFromProductGroup(productGroupId i
}
}
return property, nil
}
}