Produkte und Properties im Server

This commit is contained in:
2026-08-16 18:22:05 +02:00
parent 5b60189b07
commit 5060fe5a2e
10 changed files with 818 additions and 14 deletions
@@ -0,0 +1,56 @@
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)
}