TreeView aufgebaut

This commit is contained in:
2026-10-04 16:41:46 +02:00
parent 7ae541aaa9
commit 5b9c2a4dae
8 changed files with 50 additions and 45 deletions
@@ -3,6 +3,7 @@ package handlers
import (
"SimplyCPQ2/internal/models"
"SimplyCPQ2/internal/services"
"net/http"
"strconv"
"github.com/gin-gonic/gin"
@@ -40,23 +41,30 @@ func (h *PropertyTypeHandler) GetPropertyTypeGroupContentById(ctx *gin.Context)
return
}
ptg, err := h.propertyTypeService.GetPropertyTypeGroupByID(id)
if err != nil {
ctx.JSON(500, gin.H{"error": "Failed to get property type group"})
return
var ptg models.PropertyTypeGroup
if id != 0 {
ptg, err = h.propertyTypeService.GetPropertyTypeGroupByID(id)
if err != nil {
ctx.JSON(500, gin.H{"error": "Failed to get property type group", "details": err.Error()})
return
}
} else {
ptg.Name = "Root"
ptg.Id = 0
ptg.ParentPropertyTypeGroupId = 0
}
// 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"})
ctx.JSON(500, gin.H{"error": "Failed to get property type group content", "details": err.Error()})
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"})
ctx.JSON(500, gin.H{"error": "Failed to get property types", "details": err.Error()})
return
}
@@ -68,9 +76,7 @@ func (h *PropertyTypeHandler) GetPropertyTypeGroupContentById(ctx *gin.Context)
PropertyTypes: pts,
}
ctx.HTML(200, "ptg_treenode.html", gin.H{
"propertyTypeGroupContent": content,
})
ctx.HTML(http.StatusOK, "ptg_treeNode", content)
// Implement the logic to get property type group content by ID here using idParam
}