Adiciona GET /api/dashboard?month=YYYY-MM com resumo mensal (% poupado, gastos por categoria, evolução 6 meses, últimas 10 transações, recorrências pendentes). HomeView.vue reescrita com 4 widgets e gráficos CSS nativos. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
31 lines
631 B
Go
31 lines
631 B
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
"financeiro-carvalho/internal/service"
|
|
)
|
|
|
|
type DashboardHandler struct {
|
|
svc *service.DashboardService
|
|
}
|
|
|
|
func NewDashboardHandler(svc *service.DashboardService) *DashboardHandler {
|
|
return &DashboardHandler{svc: svc}
|
|
}
|
|
|
|
func (h *DashboardHandler) Get(w http.ResponseWriter, r *http.Request) {
|
|
month := r.URL.Query().Get("month")
|
|
if month == "" {
|
|
month = time.Now().Format("2006-01")
|
|
}
|
|
|
|
data, err := h.svc.Get(r.Context(), month)
|
|
if err != nil {
|
|
respondError(w, http.StatusInternalServerError, "failed to load dashboard")
|
|
return
|
|
}
|
|
respondJSON(w, http.StatusOK, data)
|
|
}
|