From c62aa672207359609be01b86b4f428e6add2f906 Mon Sep 17 00:00:00 2001 From: tsindt Date: Mon, 14 Sep 2026 08:52:52 +0200 Subject: [PATCH] Test --- xcpq/.ignore | 0 .../xcpq_editor/cmd/server/httpServer.go | 4 + .../xcpq_editor/data/propertyTypeGroups.json | 97 +++++++++++++++++++ .../internal/handlers/import_handler.go | 22 +++++ .../xcpq_editor/internal/models/.ignore | 0 .../xcpq_editor/internal/models/property.go | 12 +-- .../internal/models/property_type.go | 10 +- .../internal/models/property_types_group.go | 12 +-- .../xcpq_editor/internal/models/value.go | 6 +- 9 files changed, 143 insertions(+), 20 deletions(-) delete mode 100644 xcpq/.ignore create mode 100644 xcpq/buildtime/xcpq_editor/data/propertyTypeGroups.json create mode 100644 xcpq/buildtime/xcpq_editor/internal/handlers/import_handler.go delete mode 100644 xcpq/buildtime/xcpq_editor/internal/models/.ignore diff --git a/xcpq/.ignore b/xcpq/.ignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/xcpq/buildtime/xcpq_editor/cmd/server/httpServer.go b/xcpq/buildtime/xcpq_editor/cmd/server/httpServer.go index 882a10f14..dfeb6da63 100644 --- a/xcpq/buildtime/xcpq_editor/cmd/server/httpServer.go +++ b/xcpq/buildtime/xcpq_editor/cmd/server/httpServer.go @@ -39,6 +39,10 @@ func InitHttpServer(config *viper.Viper, dbHandler *sql.DB) HttpServer { router.GET("/translations", handlers.TranslationsHandler) */ + // import + router.POST("/import", handlers.ImportHandler_PropertyTypesGroup) + + // test endpoint router.GET("/test", Test) // server diff --git a/xcpq/buildtime/xcpq_editor/data/propertyTypeGroups.json b/xcpq/buildtime/xcpq_editor/data/propertyTypeGroups.json new file mode 100644 index 000000000..b21b5d8e3 --- /dev/null +++ b/xcpq/buildtime/xcpq_editor/data/propertyTypeGroups.json @@ -0,0 +1,97 @@ +[{ + "name": "Simply CPQ", + "description": "Property Type Group for Simply CPQ", + "property_types_groups": [ + { + "name": "electrical", + "description": "All electrical property types", + "property_types": [ + { + "name": "Spannungsversorgung (V)", + "description": "Spannungsversorgung (V)" + }, + { + "name": "Leistung (W)", + "description": "Leistung" + }, + { + "name": "Eingangsimpedanz (Ω)", + "description": "Wiederstand der Eingangsimpedanz" + }, + { + "name": "Frequenzbereich (Hz‑kHz)", + "description": "Frequenzbereich (Hz‑kHz)" + }, + { + "name": "Signal‑Rausch‑Verhältnis (dB)", + "description": "Signal‑Rausch‑Verhältnis (dB)" + }, + { + "name": "Anschlüsse", + "description": "Anschlüsse" + }, + { + "name": "Ausgangsimpedanz (Ω)", + "description": "Ausgangsimpedanz (Ω)" + } + ] + }, + { + "name": "mechanical", + "description": "All mechanical properties", + "property_types":[ + { + "name": "Abmessungen (mm)", + "description": "All mechanical properties" + }, + { + "name": "Gewicht (kg)", + "description": "All mechanical properties" + }, + { + "name": "Kapazität (kg)", + "description": "All mechanical properties" + }, + { + "name": "Programms/Features", + "description": "All mechanical properties" + }, + { + "name": "Wasserverbrauch pro Zyklus (L)", + "description": "All mechanical properties" + }, + { + "name": "Material Innenraum", + "description": "All mechanical properties" + } { + "name": "Kapazität/Volumen (L)", + "description": "All mechanical properties" + }, + { + "name": "Schleuderdrehzahl (U/min)", + "description": "All mechanical properties" + } + ] + }, + { + "name": "other", + "description": "All other properties", + "property_types":[ + { + "name": "Preis (USD)", + "description": "All other properties" + }, + { + "name": "Zusatzfunktionen", + "description": "All other properties" + }, { + "name": "Bedienungsart", + "description": "All other properties" + }, { + "name": "Energieeffizienzklasse", + "description": "All other properties" + } + ] + } + ] +}] \ No newline at end of file diff --git a/xcpq/buildtime/xcpq_editor/internal/handlers/import_handler.go b/xcpq/buildtime/xcpq_editor/internal/handlers/import_handler.go new file mode 100644 index 000000000..85e9aaf58 --- /dev/null +++ b/xcpq/buildtime/xcpq_editor/internal/handlers/import_handler.go @@ -0,0 +1,22 @@ +package handlers + +import ( + "net/http" + "xcpq_editor/internal/models" + + "github.com/gin-gonic/gin" +) + +func ImportHandler_PropertyTypesGroup(ctx *gin.Context) { + // Handle the import request here + + var importData []models.Property_Types_Group + if err := ctx.ShouldBindJSON(&importData); err != nil { + ctx.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + ctx.JSON(http.StatusOK, gin.H{ + "message": "Import successful", + }) +} diff --git a/xcpq/buildtime/xcpq_editor/internal/models/.ignore b/xcpq/buildtime/xcpq_editor/internal/models/.ignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/xcpq/buildtime/xcpq_editor/internal/models/property.go b/xcpq/buildtime/xcpq_editor/internal/models/property.go index f290e5b59..b8463a532 100644 --- a/xcpq/buildtime/xcpq_editor/internal/models/property.go +++ b/xcpq/buildtime/xcpq_editor/internal/models/property.go @@ -1,10 +1,10 @@ package models type Property struct { - Id int - Name string - Description string - Image_Url string - Parent_Property *Property - Values []Value + Id int `json:"id"` + Name string `json:"name"` + Description string `json:"description,omitempty"` + Image_Url string `json:"image_url,omitempty"` + Parent_Property *Property `json:"parent_property,omitempty"` + Values []Value `json:"values,omitempty"` } diff --git a/xcpq/buildtime/xcpq_editor/internal/models/property_type.go b/xcpq/buildtime/xcpq_editor/internal/models/property_type.go index ee49b3958..645beee8b 100644 --- a/xcpq/buildtime/xcpq_editor/internal/models/property_type.go +++ b/xcpq/buildtime/xcpq_editor/internal/models/property_type.go @@ -1,9 +1,9 @@ package models type Property_Type struct { - Id int - Name string - Description string - Image_Url string - Property Property + Id int `json:"id"` + Name string `json:"name"` + Description string `json:"description,omitempty"` + Image_Url string `json:"image_url,omitempty"` + Property Property `json:"property,omitempty"` } diff --git a/xcpq/buildtime/xcpq_editor/internal/models/property_types_group.go b/xcpq/buildtime/xcpq_editor/internal/models/property_types_group.go index bee082561..7ddd01afa 100644 --- a/xcpq/buildtime/xcpq_editor/internal/models/property_types_group.go +++ b/xcpq/buildtime/xcpq_editor/internal/models/property_types_group.go @@ -1,10 +1,10 @@ package models type Property_Types_Group struct { - Id int - Name string - Description string - Image_Url string - Property_Types []Property_Type - Property_Types_Groups []Property_Types_Group + Id int `json:"id"` + Name string `json:"name"` + Description string `json:"description,omitempty"` + Image_Url string `json:"image_url,omitempty"` + Property_Types []Property_Type `json:"property_types,omitempty"` + Property_Types_Groups []Property_Types_Group `json:"property_types_groups,omitempty"` } diff --git a/xcpq/buildtime/xcpq_editor/internal/models/value.go b/xcpq/buildtime/xcpq_editor/internal/models/value.go index d353399c0..feca6805a 100644 --- a/xcpq/buildtime/xcpq_editor/internal/models/value.go +++ b/xcpq/buildtime/xcpq_editor/internal/models/value.go @@ -1,7 +1,7 @@ package models type Value struct { - Id int - Value string - Image_Url string + Id int `json:"id"` + Value string `json:"value"` + Image_Url string `json:"image_url,omitempty"` }