FDN-01: repository & projektgerüst

Git-Repository für bestehenden archivdms-Code initialisiert, Branch-/Commit-Konvention (feature/<ticket>-<slug>-Branches, Ticket-Prefix in Commit-Nachricht) etabliert.
This commit is contained in:
2026-08-11 21:27:53 +02:00
parent 40ed80da71
commit 9a24ea29e1
274 changed files with 53708 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
package api
import (
"net/http"
"archivdms/internal/storage"
)
// handleDashboard returns aggregated, tenant-scoped key figures for the
// dashboard (GET /api/dashboard). Any authenticated user may view their own
// tenant's stats — no admin role required. Read-only, so no audit-log entry.
// Superadmin accounts have no tenant_id (by design, see auth.Manager.issueToken);
// they get an empty/zeroed snapshot instead of a 403, since there is no
// single tenant to scope the query to.
func (s *Server) handleDashboard(w http.ResponseWriter, r *http.Request) {
sess := sessionFromCtx(r.Context())
if sess.TenantID == nil {
writeJSON(w, http.StatusOK, &storage.DashboardStats{})
return
}
stats, err := s.store.GetDashboardStats(r.Context(), *sess.TenantID, sess.UserID)
if err != nil {
s.logger.Error("dashboard stats failed", "err", err)
writeError(w, http.StatusInternalServerError, "dashboard stats failed")
return
}
writeJSON(w, http.StatusOK, stats)
}