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
@@ -2,6 +2,7 @@ package handlers
import (
"SimplyCPQ2/internal/services"
"strconv"
"github.com/gin-gonic/gin"
)
@@ -16,6 +17,40 @@ func NewPropertyTypeHandler(propertyTypeService *services.PropertyTypeService) *
}
}
// Dummy Methode
func (h *PropertyTypeHandler) GetRootPropertyTypeGroups(ctx *gin.Context) {
// Implement the logic to get root property types groups here
}
func (h *PropertyTypeHandler) GetPropertyTypeGroupContentById(ctx *gin.Context) {
idParam := ctx.Param("id")
// Convert idParam to an integer
id, err := strconv.Atoi(idParam)
if err != nil {
ctx.JSON(400, gin.H{"error": "Invalid ID"})
return
}
// get property type groups by parent ID
ptgs, err := h.propertyTypeService.GetPropertyTypeGroupsByParentId(id)
if err != nil {
ctx.JSON(500, gin.H{"error": "Failed to get property type group content"})
return
}
// get property types by parent ID
pts, err := h.propertyTypeService.GetPropertyTypesByGroupId(id)
if err != nil {
ctx.JSON(500, gin.H{"error": "Failed to get property types"})
return
}
// template for response
ctx.JSON(200, gin.H{
"propertyTypeGroups": ptgs,
"propertyTypes": pts,
})
// Implement the logic to get property type group content by ID here using idParam
}