Bugfixes
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ func (vr *ValueRepository) GetPropertyTypesByGroupId(groupId int) ([]*models.Pro
|
||||
|
||||
func (vr *ValueRepository) CreateValueForPropertyTypeId(propertyTypeId int, value *models.Value) (*models.Value, error) {
|
||||
// Implement the logic to insert the value into the database for the given propertyTypeId
|
||||
query := `INSERT INTO values(propertytypeid, label, description) VALUES($1,$2,$3) RETURNING id`
|
||||
query := `INSERT INTO values(propertyid, label, description) VALUES($1,$2,$3) RETURNING id`
|
||||
err := vr.db.QueryRow(query, propertyTypeId, value.Label, value.Description).Scan(&value.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -179,7 +179,7 @@ func (vr *ValueRepository) CreateValueForPropertyTypeId(propertyTypeId int, valu
|
||||
|
||||
func (vr *ValueRepository) DeleteValueFromPropertyTypeId(propertyTypeId int) error {
|
||||
// Implement the logic to delete the value from the database for the given propertyTypeId
|
||||
query := `DELETE FROM values WHERE propertytypeid=$1`
|
||||
query := `DELETE FROM values WHERE propertid=$1`
|
||||
_, err := vr.db.Exec(query, propertyTypeId)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -189,7 +189,7 @@ func (vr *ValueRepository) DeleteValueFromPropertyTypeId(propertyTypeId int) err
|
||||
|
||||
func (vr *ValueRepository) GetValuesFromPropertyTypeId(propertyTypeId int) ([]*models.Value, error) {
|
||||
// Implement the logic to retrieve the values from the database for the given propertyTypeId
|
||||
query := `SELECT id, label, description FROM values WHERE propertytypeid=$1`
|
||||
query := `SELECT id, label, description FROM values WHERE propertyid=$1`
|
||||
rows, err := vr.db.Query(query, propertyTypeId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user