edit transactions in bulk

This commit is contained in:
Fran Jurmanović
2021-10-28 23:39:45 +02:00
parent 4f667c9034
commit 9e2b8322bd
2 changed files with 57 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ func NewTransactionController(as *services.TransactionService, s *gin.RouterGrou
s.PUT("/:id", wc.Edit)
s.GET("/:id", wc.Get)
s.GET("check", wc.Check)
s.PUT("/bulk", wc.BulkEdit)
return wc
}
@@ -111,6 +112,23 @@ func (wc *TransactionController) Edit(c *gin.Context) {
c.JSON(200, wm)
}
/*
BulkEdit
Args:
*gin.Context: Gin Application Context
*/
// ROUTE (PUT /transactions/:id)
func (wc *TransactionController) BulkEdit(c *gin.Context) {
body := new([]models.TransactionEdit)
if err := c.ShouldBind(body); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
wm := wc.TransactionService.BulkEdit(c, body)
c.JSON(200, wm)
}
/*
Get
Args: