package main import ( "time" ) // User represents a registered user type User struct { ID int `json:"id" db:"id"` Username string `json:"username" db:"username"` Email string `json:"email" db:"email"` Password string `json:"-" db:"password"` // Hidden from JSON CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` } // Counter represents a counter entity type Counter struct { ID int `json:"id" db:"id"` UserID *int `json:"user_id,omitempty" db:"user_id"` // nil for anonymous users Name string `json:"name" db:"name"` Description string `json:"description" db:"description"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` } // CounterEntry represents a single increment/decrement entry type CounterEntry struct { ID int `json:"id" db:"id"` CounterID int `json:"counter_id" db:"counter_id"` Value int `json:"value" db:"value"` // +1 for increment, -1 for decrement Date time.Time `json:"date" db:"date"` CreatedAt time.Time `json:"created_at" db:"created_at"` } // CounterWithStats represents a counter with aggregated statistics type CounterWithStats struct { Counter TotalValue int `json:"total_value"` TodayValue int `json:"today_value"` WeekValue int `json:"week_value"` MonthValue int `json:"month_value"` EntryCount int `json:"entry_count"` } // AnonymousCounter represents a counter for anonymous users (stored in localStorage) type AnonymousCounter struct { ID string `json:"id"` Name string `json:"name"` Description string `json:"description"` TotalValue int `json:"total_value"` Entries map[string]int `json:"entries"` // date -> count CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } // Request/Response DTOs type RegisterRequest struct { Username string `json:"username" binding:"required,min=3,max=50"` Email string `json:"email" binding:"required,email"` Password string `json:"password" binding:"required,min=6"` } type LoginRequest struct { Username string `json:"username" binding:"required"` Password string `json:"password" binding:"required"` } type AuthResponse struct { Token string `json:"token"` User User `json:"user"` } type CreateCounterRequest struct { Name string `json:"name" binding:"required,min=1,max=100"` Description string `json:"description" max:"500"` } type UpdateCounterRequest struct { Name string `json:"name" binding:"required,min=1,max=100"` Description string `json:"description" max:"500"` } type IncrementRequest struct { Value int `json:"value" binding:"required"` } type CounterStatsRequest struct { StartDate *time.Time `json:"start_date"` EndDate *time.Time `json:"end_date"` }