Install LOC guardrails (check-loc.sh, architecture.md, pre-commit hook) and split all 44 files exceeding 500 LOC into domain-focused modules: - consent-service (Go): models, handlers, services, database splits - backend-core (Python): security_api, rbac_api, pdf_service, auth splits - admin-core (TypeScript): 5 page.tsx + sidebar extractions - pitch-deck (TypeScript): 6 slides, 3 UI components, engine.ts splits - voice-service (Python): enhanced_task_orchestrator split Result: 0 violations, 36 exempted (pipeline, tests, pure-data files). Go build verified clean. No behavior changes — pure structural splits. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
119 lines
4.8 KiB
Go
119 lines
4.8 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// CookieCategory represents a category of cookies
|
|
type CookieCategory struct {
|
|
ID uuid.UUID `json:"id" db:"id"`
|
|
Name string `json:"name" db:"name"` // 'necessary', 'functional', 'analytics', 'marketing'
|
|
DisplayNameDE string `json:"display_name_de" db:"display_name_de"`
|
|
DisplayNameEN *string `json:"display_name_en" db:"display_name_en"`
|
|
DescriptionDE *string `json:"description_de" db:"description_de"`
|
|
DescriptionEN *string `json:"description_en" db:"description_en"`
|
|
IsMandatory bool `json:"is_mandatory" db:"is_mandatory"`
|
|
SortOrder int `json:"sort_order" db:"sort_order"`
|
|
IsActive bool `json:"is_active" db:"is_active"`
|
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
|
}
|
|
|
|
// CookieConsent represents a user's cookie preferences
|
|
type CookieConsent struct {
|
|
ID uuid.UUID `json:"id" db:"id"`
|
|
UserID uuid.UUID `json:"user_id" db:"user_id"`
|
|
CategoryID uuid.UUID `json:"category_id" db:"category_id"`
|
|
Consented bool `json:"consented" db:"consented"`
|
|
ConsentedAt time.Time `json:"consented_at" db:"consented_at"`
|
|
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
|
}
|
|
|
|
// CookieConsentRequest is the request body for setting cookie preferences
|
|
type CookieConsentRequest struct {
|
|
Categories []CookieCategoryConsent `json:"categories" binding:"required"`
|
|
}
|
|
|
|
// CookieCategoryConsent represents consent for a single cookie category
|
|
type CookieCategoryConsent struct {
|
|
CategoryID string `json:"category_id" binding:"required"`
|
|
Consented bool `json:"consented"`
|
|
}
|
|
|
|
// CookieStats represents statistics about cookie consents
|
|
type CookieStats struct {
|
|
Category string `json:"category"`
|
|
TotalUsers int `json:"total_users"`
|
|
ConsentedUsers int `json:"consented_users"`
|
|
ConsentRate float64 `json:"consent_rate"`
|
|
}
|
|
|
|
// CreateCookieCategoryRequest is the request body for creating a cookie category
|
|
type CreateCookieCategoryRequest struct {
|
|
Name string `json:"name" binding:"required"`
|
|
DisplayNameDE string `json:"display_name_de" binding:"required"`
|
|
DisplayNameEN *string `json:"display_name_en"`
|
|
DescriptionDE *string `json:"description_de"`
|
|
DescriptionEN *string `json:"description_en"`
|
|
IsMandatory bool `json:"is_mandatory"`
|
|
SortOrder int `json:"sort_order"`
|
|
}
|
|
|
|
// ========================================
|
|
// Notification Models
|
|
// ========================================
|
|
|
|
// Notification represents a user notification
|
|
type Notification struct {
|
|
ID uuid.UUID `json:"id" db:"id"`
|
|
UserID uuid.UUID `json:"user_id" db:"user_id"`
|
|
Type string `json:"type" db:"type"` // 'new_version', 'consent_reminder', 'account_warning'
|
|
Channel string `json:"channel" db:"channel"` // 'email', 'in_app', 'push'
|
|
Title string `json:"title" db:"title"`
|
|
Body string `json:"body" db:"body"`
|
|
Data *string `json:"data,omitempty" db:"data"` // JSON string
|
|
ReadAt *time.Time `json:"read_at,omitempty" db:"read_at"`
|
|
SentAt *time.Time `json:"sent_at,omitempty" db:"sent_at"`
|
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
|
}
|
|
|
|
// PushSubscription for Web Push notifications
|
|
type PushSubscription struct {
|
|
ID uuid.UUID `json:"id" db:"id"`
|
|
UserID uuid.UUID `json:"user_id" db:"user_id"`
|
|
Endpoint string `json:"endpoint" db:"endpoint"`
|
|
P256dh string `json:"p256dh" db:"p256dh"`
|
|
Auth string `json:"auth" db:"auth"`
|
|
UserAgent *string `json:"user_agent,omitempty" db:"user_agent"`
|
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
|
}
|
|
|
|
// NotificationPreferences for user notification settings
|
|
type NotificationPreferences struct {
|
|
ID uuid.UUID `json:"id" db:"id"`
|
|
UserID uuid.UUID `json:"user_id" db:"user_id"`
|
|
EmailEnabled bool `json:"email_enabled" db:"email_enabled"`
|
|
PushEnabled bool `json:"push_enabled" db:"push_enabled"`
|
|
InAppEnabled bool `json:"in_app_enabled" db:"in_app_enabled"`
|
|
ReminderFrequency string `json:"reminder_frequency" db:"reminder_frequency"` // 'daily', 'weekly', 'never'
|
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
|
}
|
|
|
|
// SubscribePushRequest for subscribing to push notifications
|
|
type SubscribePushRequest struct {
|
|
Endpoint string `json:"endpoint" binding:"required"`
|
|
P256dh string `json:"p256dh" binding:"required"`
|
|
Auth string `json:"auth" binding:"required"`
|
|
}
|
|
|
|
// UpdateNotificationPreferencesRequest for updating preferences
|
|
type UpdateNotificationPreferencesRequest struct {
|
|
EmailEnabled *bool `json:"email_enabled"`
|
|
PushEnabled *bool `json:"push_enabled"`
|
|
InAppEnabled *bool `json:"in_app_enabled"`
|
|
ReminderFrequency *string `json:"reminder_frequency"`
|
|
}
|