package handlers import ( "context" "strconv" "github.com/breakpilot/consent-service/internal/database" "github.com/google/uuid" ) // Handler holds all HTTP handlers type Handler struct { db *database.DB } // New creates a new Handler instance func New(db *database.DB) *Handler { return &Handler{db: db} } // ======================================== // HELPER FUNCTIONS // ======================================== func (h *Handler) logAudit(ctx context.Context, userID *uuid.UUID, action, entityType string, entityID *uuid.UUID, details *string, ipAddress, userAgent string) { h.db.Pool.Exec(ctx, ` INSERT INTO consent_audit_log (user_id, action, entity_type, entity_id, details, ip_address, user_agent) VALUES ($1, $2, $3, $4, $5, $6, $7) `, userID, action, entityType, entityID, details, ipAddress, userAgent) } func parseIntFromQuery(s string) (int, error) { return strconv.Atoi(s) }