Files
simply_cpq/buildtime/server/services/productService.go
T

52 lines
1.5 KiB
Go

package services
import (
"simplycpq/models"
"simplycpq/repositories"
)
type ProductService struct {
productRepository *repositories.ProductRepository
}
func NewProductService(productRepository *repositories.ProductRepository) *ProductService {
return &ProductService{
productRepository: productRepository,
}
}
func (s *ProductService) CreateProduct(product *models.Product) (*models.Product, error) {
return s.productRepository.CreateProduct(product)
}
func (s *ProductService) UpdateProduct(product *models.Product) error {
return s.productRepository.UpdateProduct(product)
}
func (s *ProductService) DeleteProduct(id int) error {
return s.productRepository.DeleteProduct(id)
}
func (s *ProductService) GetProduct(id int) (*models.Product, error) {
return s.productRepository.GetProductById(id)
}
func (s *ProductService) GetProductById(id int) (*models.Product, error) {
return s.productRepository.GetProductById(id)
}
func (s *ProductService) GetProductsByGroupId(groupId int) ([]*models.Product, error) {
return s.productRepository.GetProductsByGroupId(groupId)
}
func (s *ProductService) AddPropertyToProduct(productId int, propertyId int) error {
return s.productRepository.AddPropertyToProduct(productId, propertyId)
}
func (s *ProductService) DeletePropertyFromProduct(productId int, propertyId int) error {
return s.productRepository.DeletePropertyFromProduct(productId, propertyId)
}
func (s *ProductService) GetPropertiesFromProduct(productId int) ([]*models.Property, error) {
return s.productRepository.GetPropertiesFromProduct(productId)
}