productRepository created
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user