75 lines
2.6 KiB
Go
75 lines
2.6 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
type Habit struct {
|
|
ID int64 `db:"id" json:"id"`
|
|
UserID int64 `db:"user_id" json:"user_id"`
|
|
Name string `db:"name" json:"name"`
|
|
Description string `db:"description" json:"description"`
|
|
Color string `db:"color" json:"color"`
|
|
Icon string `db:"icon" json:"icon"`
|
|
Frequency string `db:"frequency" json:"frequency"` // daily, weekly, custom
|
|
TargetDays []int `db:"-" json:"target_days"` // 0=Sun, 1=Mon, etc.
|
|
TargetCount int `db:"target_count" json:"target_count"`
|
|
IsArchived bool `db:"is_archived" json:"is_archived"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
|
}
|
|
|
|
type HabitLog struct {
|
|
ID int64 `db:"id" json:"id"`
|
|
HabitID int64 `db:"habit_id" json:"habit_id"`
|
|
UserID int64 `db:"user_id" json:"user_id"`
|
|
Date time.Time `db:"date" json:"date"`
|
|
Count int `db:"count" json:"count"`
|
|
Note string `db:"note" json:"note"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
}
|
|
|
|
type CreateHabitRequest struct {
|
|
Name string `json:"name"`
|
|
Description string `json:"description,omitempty"`
|
|
Color string `json:"color,omitempty"`
|
|
Icon string `json:"icon,omitempty"`
|
|
Frequency string `json:"frequency,omitempty"`
|
|
TargetDays []int `json:"target_days,omitempty"`
|
|
TargetCount int `json:"target_count,omitempty"`
|
|
}
|
|
|
|
type UpdateHabitRequest struct {
|
|
Name *string `json:"name,omitempty"`
|
|
Description *string `json:"description,omitempty"`
|
|
Color *string `json:"color,omitempty"`
|
|
Icon *string `json:"icon,omitempty"`
|
|
Frequency *string `json:"frequency,omitempty"`
|
|
TargetDays []int `json:"target_days,omitempty"`
|
|
TargetCount *int `json:"target_count,omitempty"`
|
|
IsArchived *bool `json:"is_archived,omitempty"`
|
|
}
|
|
|
|
type LogHabitRequest struct {
|
|
Date string `json:"date,omitempty"` // YYYY-MM-DD, defaults to today
|
|
Count int `json:"count,omitempty"`
|
|
Note string `json:"note,omitempty"`
|
|
}
|
|
|
|
type HabitStats struct {
|
|
HabitID int64 `json:"habit_id"`
|
|
TotalLogs int `json:"total_logs"`
|
|
CurrentStreak int `json:"current_streak"`
|
|
LongestStreak int `json:"longest_streak"`
|
|
CompletionPct float64 `json:"completion_pct"`
|
|
ThisWeek int `json:"this_week"`
|
|
ThisMonth int `json:"this_month"`
|
|
}
|
|
|
|
type OverallStats struct {
|
|
TotalHabits int `json:"total_habits"`
|
|
ActiveHabits int `json:"active_habits"`
|
|
TodayCompleted int `json:"today_completed"`
|
|
WeeklyAvg float64 `json:"weekly_avg"`
|
|
}
|