productRepository created

This commit is contained in:
2026-07-15 15:25:50 +05:30
parent 7e9b3f98ba
commit 950064de6c
8 changed files with 62 additions and 1 deletions

View File

@@ -35,6 +35,7 @@ type ProductRepository interface {
UpdateProductLocation(input models.Productlocations) error
CreateProductLocation(input []models.Productlocations) error
CreateProductVariant(input models.Productvariant) error
DeleteProductLocation(tenantid, locationid, productid int) error
}
type productRepository struct {
@@ -695,7 +696,7 @@ func (r *productRepository) CreateProductLocation(input []models.Productlocation
// Insert or update product location
if err := tx.Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "tenantid"}, {Name: "locationid"}, {Name: "productid"}},
DoUpdates: clause.AssignmentColumns([]string{"price", "minquantity", "maxquantity"}),
DoUpdates: clause.AssignmentColumns([]string{"price", "minquantity", "maxquantity", "status"}),
}).Create(&input).Error; err != nil {
tx.Rollback()
return err
@@ -745,3 +746,10 @@ func (r *productRepository) CreateProductVariant(input models.Productvariant) er
return nil
}
func (r *productRepository) DeleteProductLocation(tenantid, locationid, productid int) error {
if err := r.db.Where("tenantid = ? AND locationid = ? AND productid = ?", tenantid, locationid, productid).Delete(&models.Productlocations{}).Error; err != nil {
return err
}
return nil
}