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,14 +16,15 @@ func (a *APIHandler) AddNewResponsible(c *gin.Context) {
return
}
var responsible models.Person
err := c.BindJSON(&responsible)
var responsibles []models.Person
err := c.BindJSON(&responsibles)
if err != nil {
a.logger.Error("AddNewResponsible", err)
c.JSON(http.StatusInternalServerError, nil)
return
}
for _, responsible := range responsibles {
err = a.DbHandler.AddNewResponsible(responsible)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{
@@ -31,9 +32,10 @@ func (a *APIHandler) AddNewResponsible(c *gin.Context) {
})
return
}
}
c.JSON(http.StatusOK, gin.H{
"message": "responsible added",
"message": "responsible(s) added",
})
}