43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package goal
|
|
|
|
import "time"
|
|
|
|
// GoalType defines categories of goals users can set.
|
|
type GoalType string
|
|
|
|
const (
|
|
GoalDistance GoalType = "distance"
|
|
GoalFrequency GoalType = "frequency"
|
|
GoalPower GoalType = "power"
|
|
GoalWeight GoalType = "weight"
|
|
GoalCustom GoalType = "custom"
|
|
)
|
|
|
|
// GoalStatus tracks the lifecycle of a goal.
|
|
type GoalStatus string
|
|
|
|
const (
|
|
StatusActive GoalStatus = "active"
|
|
StatusCompleted GoalStatus = "completed"
|
|
StatusArchived GoalStatus = "archived"
|
|
)
|
|
|
|
type Goal struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
UserID uint `gorm:"not null;index" json:"user_id"`
|
|
Title string `gorm:"not null" json:"title"`
|
|
Description string `gorm:"default:''" json:"description"`
|
|
GoalType GoalType `gorm:"default:'custom'" json:"goal_type"`
|
|
TargetValue float64 `gorm:"not null;default:0" json:"target_value"`
|
|
CurrentValue float64 `gorm:"default:0" json:"current_value"`
|
|
TargetDate *time.Time `json:"target_date,omitempty"`
|
|
Status GoalStatus `gorm:"default:'active'" json:"status"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (Goal) TableName() string {
|
|
return "goals"
|
|
}
|
|
|