Erweiterung der Produktpflege
This commit is contained in:
@@ -27,22 +27,23 @@ func (bc *BOMController) CreateBillOfMaterial(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
err = bc.bomService.CreateBillOfMaterial(&bom)
|
||||
createdBOM, err := bc.bomService.CreateBillOfMaterial(&bom)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.Status(http.StatusCreated)
|
||||
c.JSON(http.StatusCreated, createdBOM)
|
||||
// Removed redundant error check and status setting
|
||||
}
|
||||
|
||||
func (bc *BOMController) GetBOMProductsByBOMId(c *gin.Context) {
|
||||
bomIdStr := c.Query("bomId")
|
||||
bomId, err := strconv.ParseInt(bomIdStr, 10, 64)
|
||||
func (bc *BOMController) GetBOMByProductID(c *gin.Context) {
|
||||
productIdStr := c.Param("productId")
|
||||
productId, err := strconv.Atoi(productIdStr)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
contents, err := bc.bomService.GetBOMProductsByBOMId(bomId)
|
||||
contents, err := bc.bomService.GetBOMByProductID(productId)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
@@ -51,8 +52,8 @@ func (bc *BOMController) GetBOMProductsByBOMId(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (bc *BOMController) GetBOMVariantNodesByBOMId(c *gin.Context) {
|
||||
bomIdStr := c.Query("bomId")
|
||||
bomId, err := strconv.ParseInt(bomIdStr, 10, 64)
|
||||
bomIdStr := c.Param("bomId")
|
||||
bomId, err := strconv.Atoi(bomIdStr)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
@@ -87,17 +88,17 @@ func (bc *BOMController) UpdateVariantNode(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
err = bc.bomService.UpdateVariantNode(&variantNode)
|
||||
updatedVariantNode, err := bc.bomService.UpdateVariantNode(&variantNode)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.Status(http.StatusOK)
|
||||
c.JSON(http.StatusOK, updatedVariantNode)
|
||||
}
|
||||
|
||||
func (bc *BOMController) DeleteVariantNode(c *gin.Context) {
|
||||
variantNodeIdStr := c.Query("variantNodeId")
|
||||
variantNodeId, err := strconv.ParseInt(variantNodeIdStr, 10, 64)
|
||||
variantNodeId, err := strconv.Atoi(variantNodeIdStr)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
@@ -112,7 +113,7 @@ func (bc *BOMController) DeleteVariantNode(c *gin.Context) {
|
||||
|
||||
func (bc *BOMController) GetVariantNode(c *gin.Context) {
|
||||
variantNodeIdStr := c.Query("variantNodeId")
|
||||
variantNodeId, err := strconv.ParseInt(variantNodeIdStr, 10, 64)
|
||||
variantNodeId, err := strconv.Atoi(variantNodeIdStr)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
@@ -127,7 +128,7 @@ func (bc *BOMController) GetVariantNode(c *gin.Context) {
|
||||
|
||||
func (bc *BOMController) GetVariantNodeProductsByVariantNodeId(c *gin.Context) {
|
||||
variantNodeIdStr := c.Query("variantNodeId")
|
||||
variantNodeId, err := strconv.ParseInt(variantNodeIdStr, 10, 64)
|
||||
variantNodeId, err := strconv.Atoi(variantNodeIdStr)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
@@ -147,17 +148,17 @@ func (bc *BOMController) UpdateBillOfMaterial(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
err = bc.bomService.UpdateBillOfMaterial(&bom)
|
||||
updatedBOM, err := bc.bomService.UpdateBillOfMaterial(&bom)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.Status(http.StatusOK)
|
||||
c.JSON(http.StatusOK, updatedBOM)
|
||||
}
|
||||
|
||||
func (bc *BOMController) DeleteBillOfMaterial(c *gin.Context) {
|
||||
bomIdStr := c.Query("id")
|
||||
bomId, err := strconv.ParseInt(bomIdStr, 10, 64)
|
||||
bomId, err := strconv.Atoi(bomIdStr)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
@@ -172,7 +173,7 @@ func (bc *BOMController) DeleteBillOfMaterial(c *gin.Context) {
|
||||
|
||||
func (bc *BOMController) GetBillOfMaterial(c *gin.Context) {
|
||||
bomIdStr := c.Query("id")
|
||||
bomId, err := strconv.ParseInt(bomIdStr, 10, 64)
|
||||
bomId, err := strconv.Atoi(bomIdStr)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
@@ -184,3 +185,18 @@ func (bc *BOMController) GetBillOfMaterial(c *gin.Context) {
|
||||
}
|
||||
c.JSON(http.StatusOK, bom)
|
||||
}
|
||||
|
||||
func (bc *BOMController) GetBOMContentByBOMId(c *gin.Context) {
|
||||
bomIdStr := c.Param("bomId")
|
||||
bomId, err := strconv.Atoi(bomIdStr)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
contents, err := bc.bomService.GetBOMContentByBOMId(bomId)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, contents)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user