db fix and new update request

This commit is contained in:
samantha42
2026-03-20 23:02:33 +01:00
parent 6ad5df839b
commit 45f4cca485
8 changed files with 187 additions and 81 deletions

View File

@@ -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