extend add responsible from single to array
This commit is contained in:
@@ -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",
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user