Backend:
- ReportingService with aggregation queries (CTEs, FILTER clauses)
- 4 API endpoints: /api/reports/{cases,deadlines,workload,billing}
- Date range filtering via ?from=&to= query params
Frontend:
- /berichte page with 4 tabs: Akten, Fristen, Auslastung, Abrechnung
- recharts: bar/pie/line charts for all report types
- Date range picker, CSV export, print-friendly view
- Sidebar nav entry with BarChart3 icon
Also resolves merge conflicts between role-based, notification, and
audit trail branches, and adds missing TS types (AuditLogResponse,
Notification, NotificationPreferences).
65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
package auth
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type contextKey string
|
|
|
|
const (
|
|
userIDKey contextKey = "user_id"
|
|
tenantIDKey contextKey = "tenant_id"
|
|
userRoleKey contextKey = "user_role"
|
|
ipKey contextKey = "ip_address"
|
|
userAgentKey contextKey = "user_agent"
|
|
)
|
|
|
|
func ContextWithUserID(ctx context.Context, userID uuid.UUID) context.Context {
|
|
return context.WithValue(ctx, userIDKey, userID)
|
|
}
|
|
|
|
func ContextWithTenantID(ctx context.Context, tenantID uuid.UUID) context.Context {
|
|
return context.WithValue(ctx, tenantIDKey, tenantID)
|
|
}
|
|
|
|
func UserFromContext(ctx context.Context) (uuid.UUID, bool) {
|
|
id, ok := ctx.Value(userIDKey).(uuid.UUID)
|
|
return id, ok
|
|
}
|
|
|
|
func TenantFromContext(ctx context.Context) (uuid.UUID, bool) {
|
|
id, ok := ctx.Value(tenantIDKey).(uuid.UUID)
|
|
return id, ok
|
|
}
|
|
|
|
func ContextWithUserRole(ctx context.Context, role string) context.Context {
|
|
return context.WithValue(ctx, userRoleKey, role)
|
|
}
|
|
|
|
func UserRoleFromContext(ctx context.Context) string {
|
|
role, _ := ctx.Value(userRoleKey).(string)
|
|
return role
|
|
}
|
|
|
|
func ContextWithRequestInfo(ctx context.Context, ip, userAgent string) context.Context {
|
|
ctx = context.WithValue(ctx, ipKey, ip)
|
|
ctx = context.WithValue(ctx, userAgentKey, userAgent)
|
|
return ctx
|
|
}
|
|
|
|
func IPFromContext(ctx context.Context) *string {
|
|
if v, ok := ctx.Value(ipKey).(string); ok && v != "" {
|
|
return &v
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func UserAgentFromContext(ctx context.Context) *string {
|
|
if v, ok := ctx.Value(userAgentKey).(string); ok && v != "" {
|
|
return &v
|
|
}
|
|
return nil
|
|
}
|