This commit is contained in:
2026-10-01 21:10:08 +02:00
parent c65f36dc40
commit 679a8a0a3e
9 changed files with 275 additions and 14 deletions
@@ -1,18 +1,41 @@
package services
import (
"SimplyCPQ2/internal/models"
"SimplyCPQ2/internal/repositories"
)
type PropertyTypeService struct {
// Add any dependencies or fields needed for the service here
values_Repository *repositories.ValueRepository
Property_Repository *repositories.PropertyRepository
PropertyTypes_Repository *repositories.PropertyTypeRepository
PropertyTypeGroups_Repository *repositories.PropertyTypeGroupRepository
}
func NewPropertyTypeService(propertyTypesRepo *repositories.PropertyTypeRepository, propertyTypesGroupsRepo *repositories.PropertyTypeGroupRepository) *PropertyTypeService {
func NewPropertyTypeService(propertyRepo *repositories.PropertyRepository, propertyTypesRepo *repositories.PropertyTypeRepository, propertyTypesGroupsRepo *repositories.PropertyTypeGroupRepository, valuesRepo *repositories.ValueRepository) *PropertyTypeService {
return &PropertyTypeService{
Property_Repository: propertyRepo,
PropertyTypes_Repository: propertyTypesRepo,
PropertyTypeGroups_Repository: propertyTypesGroupsRepo,
values_Repository: valuesRepo,
}
}
// Getter functions
func (service *PropertyTypeService) GetPropertyTypeGroupsByParentId(parentId int) ([]models.PropertyTypeGroup, error) {
return service.PropertyTypeGroups_Repository.GetPropertyTypesByGroupId(parentId)
}
func (service *PropertyTypeService) GetPropertyTypesByGroupId(id int) ([]models.PropertyType, error) {
return service.PropertyTypes_Repository.GetPropertyTypesByGroupID(id)
}
func (service *PropertyTypeService) GetPropertyByTypeId(id int) (models.Property, error) {
return service.Property_Repository.GetPropertyByPropertyTypeID(id)
}
func (service *PropertyTypeService) GetValuesByPropertyId(id int) ([]models.Value, error) {
return service.values_Repository.GetValuesByPropertyId(id)
}