extend add responsible from single to array

This commit is contained in:
Adrian Zürcher
2025-11-06 15:10:28 +01:00
parent a20a21d251
commit 103a07b7ac

View File

@@ -16,24 +16,26 @@ 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
}
err = a.DbHandler.AddNewResponsible(responsible)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"message": err.Error(),
})
return
for _, responsible := range responsibles {
err = a.DbHandler.AddNewResponsible(responsible)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"message": err.Error(),
})
return
}
}
c.JSON(http.StatusOK, gin.H{
"message": "responsible added",
"message": "responsible(s) added",
})
}