db fix and new update request
This commit is contained in:
@@ -37,16 +37,12 @@ func (h *BudgetHandler) Update(w http.ResponseWriter, r *http.Request) {
|
||||
writeError(w, http.StatusBadRequest, "invalid id")
|
||||
return
|
||||
}
|
||||
var body struct {
|
||||
Amount float64 `json:"amount"`
|
||||
Notes string `json:"notes"`
|
||||
ChangedBy string `json:"changed_by"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
||||
var req model.UpdateBudgetRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
writeError(w, http.StatusBadRequest, "invalid request body")
|
||||
return
|
||||
}
|
||||
budget, err := h.svc.Update(r.Context(), id, body.Amount, body.Notes, body.ChangedBy)
|
||||
budget, err := h.svc.Update(r.Context(), id, req)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user