feat: Add data models and PostgreSQL storage layer
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
114
backend/internal/models/models.go
Normal file
114
backend/internal/models/models.go
Normal file
@@ -0,0 +1,114 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// ExerciseType represents the type of exercise
|
||||
type ExerciseType string
|
||||
|
||||
const (
|
||||
ExerciseTypeStrength ExerciseType = "strength"
|
||||
ExerciseTypeCardio ExerciseType = "cardio"
|
||||
)
|
||||
|
||||
// Exercise represents an exercise definition
|
||||
type Exercise struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Type ExerciseType `json:"type"`
|
||||
MuscleGroup string `json:"muscle_group,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// TrainingPlan represents a training plan template
|
||||
type TrainingPlan struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Exercises []PlanExercise `json:"exercises,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// PlanExercise represents an exercise within a training plan
|
||||
type PlanExercise struct {
|
||||
ID int64 `json:"id"`
|
||||
PlanID int64 `json:"plan_id"`
|
||||
ExerciseID int64 `json:"exercise_id"`
|
||||
Exercise Exercise `json:"exercise,omitempty"`
|
||||
Sets int `json:"sets,omitempty"`
|
||||
Reps int `json:"reps,omitempty"`
|
||||
Duration int `json:"duration,omitempty"` // in seconds
|
||||
Order int `json:"order"`
|
||||
}
|
||||
|
||||
// Session represents a completed training session
|
||||
type Session struct {
|
||||
ID int64 `json:"id"`
|
||||
PlanID *int64 `json:"plan_id,omitempty"`
|
||||
Plan *TrainingPlan `json:"plan,omitempty"`
|
||||
Date time.Time `json:"date"`
|
||||
Notes string `json:"notes,omitempty"`
|
||||
Entries []SessionEntry `json:"entries,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// SessionEntry represents an individual exercise entry in a session
|
||||
type SessionEntry struct {
|
||||
ID int64 `json:"id"`
|
||||
SessionID int64 `json:"session_id"`
|
||||
ExerciseID int64 `json:"exercise_id"`
|
||||
Exercise *Exercise `json:"exercise,omitempty"`
|
||||
Weight float64 `json:"weight,omitempty"` // in kg
|
||||
Reps int `json:"reps,omitempty"` // for strength
|
||||
SetsCompleted int `json:"sets_completed,omitempty"`
|
||||
Duration int `json:"duration,omitempty"` // in seconds, for cardio
|
||||
Distance float64 `json:"distance,omitempty"` // in km, for cardio
|
||||
HeartRate int `json:"heart_rate,omitempty"` // average HR
|
||||
Notes string `json:"notes,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// CreateExerciseRequest represents the request to create an exercise
|
||||
type CreateExerciseRequest struct {
|
||||
Name string `json:"name"`
|
||||
Type ExerciseType `json:"type"`
|
||||
MuscleGroup string `json:"muscle_group,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
}
|
||||
|
||||
// CreatePlanRequest represents the request to create a training plan
|
||||
type CreatePlanRequest struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Exercises []PlanExerciseInput `json:"exercises,omitempty"`
|
||||
}
|
||||
|
||||
// PlanExerciseInput represents exercise input for plan creation
|
||||
type PlanExerciseInput struct {
|
||||
ExerciseID int64 `json:"exercise_id"`
|
||||
Sets int `json:"sets,omitempty"`
|
||||
Reps int `json:"reps,omitempty"`
|
||||
Duration int `json:"duration,omitempty"`
|
||||
Order int `json:"order"`
|
||||
}
|
||||
|
||||
// CreateSessionRequest represents the request to create a session
|
||||
type CreateSessionRequest struct {
|
||||
PlanID *int64 `json:"plan_id,omitempty"`
|
||||
Date time.Time `json:"date"`
|
||||
Notes string `json:"notes,omitempty"`
|
||||
}
|
||||
|
||||
// CreateSessionEntryRequest represents the request to add an entry to a session
|
||||
type CreateSessionEntryRequest struct {
|
||||
ExerciseID int64 `json:"exercise_id"`
|
||||
Weight float64 `json:"weight,omitempty"`
|
||||
Reps int `json:"reps,omitempty"`
|
||||
SetsCompleted int `json:"sets_completed,omitempty"`
|
||||
Duration int `json:"duration,omitempty"`
|
||||
Distance float64 `json:"distance,omitempty"`
|
||||
HeartRate int `json:"heart_rate,omitempty"`
|
||||
Notes string `json:"notes,omitempty"`
|
||||
}
|
||||
Reference in New Issue
Block a user