Import Serverfunktionen angelegt
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"simplycpq/models"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ImportController struct {
|
||||
importService *ImportService
|
||||
}
|
||||
|
||||
func NewImportController(i *ImportService) *ImportController {
|
||||
return &ImportController{
|
||||
importService: i,
|
||||
}
|
||||
}
|
||||
|
||||
func (ic *ImportController) ImportPropertyTypeGroups(c *gin.Context) {
|
||||
// Implement the logic for importing PropertyTypeGroups here
|
||||
var importData []models.ImportPropertyTypeGroup
|
||||
if err := c.ShouldBindJSON(&importData); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
serviceErr := ic.importService.ImportPropertyTypeGroups(importData)
|
||||
if serviceErr != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": serviceErr.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"message": "Import PropertyTypeGroups endpoint"})
|
||||
}
|
||||
|
||||
func (ic *ImportController) ImportProductGroups(c *gin.Context) {
|
||||
// Implement the logic for importing ProductGroups here
|
||||
var importData []models.ImportProductGroup
|
||||
if err := c.ShouldBindJSON(&importData); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
serviceErr := ic.importService.ImportProductGroups(importData)
|
||||
if serviceErr != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": serviceErr.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"message": "Import ProductGroups endpoint"})
|
||||
}
|
||||
|
||||
func (ic *ImportController) ImportProducts(c *gin.Context) {
|
||||
// Implement the logic for importing Products here
|
||||
var importData []models.ImportProduct
|
||||
if err := c.ShouldBindJSON(&importData); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
serviceErr := ic.importService.ImportProducts(importData)
|
||||
if serviceErr != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": serviceErr.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"message": "Import Products endpoint"})
|
||||
}
|
||||
Reference in New Issue
Block a user