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

57 lines
2.1 KiB
Go

package services
import (
"simplycpq/models"
"simplycpq/repositories"
)
type ProductGroupService struct {
productGroupRepository *repositories.ProductGroupRepository
}
func NewProductGroupService(productGroupRepository *repositories.ProductGroupRepository) *ProductGroupService {
return &ProductGroupService{
productGroupRepository: productGroupRepository,
}
}
func (s *ProductGroupService) CreateProductGroup(productGroup *models.ProductGroup) (*models.ProductGroup, error) {
return s.productGroupRepository.CreateProductGroup(productGroup)
}
func (s *ProductGroupService) UpdateProductGroup(productGroup *models.ProductGroup) (*models.ProductGroup, error) {
return s.productGroupRepository.UpdateProductGroup(productGroup)
}
func (s *ProductGroupService) DeleteProductGroup(id int) error {
return s.productGroupRepository.DeleteProductGroup(id)
}
func (s *ProductGroupService) GetProductGroup(id int) (*models.ProductGroup, error) {
return s.productGroupRepository.GetProductGroup(id)
}
func (s *ProductGroupService) GetPropertiesFromProductGroupId(id int) ([]*models.Property, error) {
return s.productGroupRepository.GetPropertiesFromProductGroupId(id)
}
func (s *ProductGroupService) GetProductGroupsByParentId(parentId int) ([]*models.ProductGroup, error) {
return s.productGroupRepository.GetProductGroupsByParentId(parentId)
}
func (s *ProductGroupService) DeleteProductFromProductGroupId(productGroupId int) error {
return s.productGroupRepository.DeleteProductFromProductGroupId(productGroupId)
}
func (s *ProductGroupService) GetPropertiesFromProductGroup(productGroupId int) ([]*models.Property, error) {
return s.productGroupRepository.GetPropertiesFromProductGroupId(productGroupId)
}
func (s *ProductGroupService) DeletePropertyFromProductGroup(productGroupId int, propertyId int) error {
return s.productGroupRepository.DeletePropertyFromProductGroup(productGroupId, propertyId)
}
func (s *ProductGroupService) CreatePropertyToProductGroupId(productGroupId int, property *models.Property) (*models.Property, error) {
return s.productGroupRepository.CreatePropertyFromProductGroup(productGroupId, property)
}