Erweiterung der Produktpflege

This commit is contained in:
2026-08-27 15:31:50 +02:00
parent b2ce536723
commit cdf7a538c1
240 changed files with 8264 additions and 6420 deletions
@@ -1,6 +1,7 @@
package controller
import (
"log"
"net/http"
"simplycpq/models"
"simplycpq/services"
@@ -264,6 +265,40 @@ func (vc *ValueController) DeleteValueFromPropertyId(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"message": "Value deleted from Property", "valueId": valueIdInt, "propertyId": propertyIdInt})
}
func (vc *ValueController) UpdateValue(c *gin.Context) {
var value models.Value
if err := c.ShouldBindJSON(&value); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
if err := vc.valueService.UpdateValue(&value); err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{"message": "Value updated", "data": value})
}
func (vc *ValueController) CreateValueForPropertyId(c *gin.Context) {
propertyId, err := strconv.Atoi(c.Param("propertyId"))
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid property id"})
return
}
var value models.Value
log.Println("Received request to create value for property ID:", propertyId) // Debugging line
log.Println("Request body:", c.Request.Body) // Debugging line
if err := c.ShouldBindJSON(&value); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
createdValue, err := vc.valueService.CreateValueForPropertyId(propertyId, &value)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{"message": "Value created for Property", "propertyId": propertyId, "data": createdValue})
}
func (vc *ValueController) GetValue(c *gin.Context) {
id := c.Param("id")
idInt, err := strconv.Atoi(id)