1 Commits

Author SHA1 Message Date
Adrian Zürcher
103a07b7ac extend add responsible from single to array 2025-11-06 15:10:28 +01:00

View File

@@ -16,24 +16,26 @@ func (a *APIHandler) AddNewResponsible(c *gin.Context) {
return return
} }
var responsible models.Person var responsibles []models.Person
err := c.BindJSON(&responsible) err := c.BindJSON(&responsibles)
if err != nil { if err != nil {
a.logger.Error("AddNewResponsible", err) a.logger.Error("AddNewResponsible", err)
c.JSON(http.StatusInternalServerError, nil) c.JSON(http.StatusInternalServerError, nil)
return return
} }
err = a.DbHandler.AddNewResponsible(responsible) for _, responsible := range responsibles {
if err != nil { err = a.DbHandler.AddNewResponsible(responsible)
c.JSON(http.StatusBadRequest, gin.H{ if err != nil {
"message": err.Error(), c.JSON(http.StatusBadRequest, gin.H{
}) "message": err.Error(),
return })
return
}
} }
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"message": "responsible added", "message": "responsible(s) added",
}) })
} }