feat: Add REST API handlers for exercises, plans, and sessions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Jan Novak
2026-01-19 19:50:09 +01:00
parent cd435a6569
commit e43373bfcf
7 changed files with 598 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
package api
import (
"context"
"training-tracker/internal/models"
)
// ExerciseRepository defines the interface for exercise storage operations
type ExerciseRepository interface {
List(ctx context.Context) ([]models.Exercise, error)
GetByID(ctx context.Context, id int64) (*models.Exercise, error)
Create(ctx context.Context, req *models.CreateExerciseRequest) (*models.Exercise, error)
Update(ctx context.Context, id int64, req *models.CreateExerciseRequest) (*models.Exercise, error)
Delete(ctx context.Context, id int64) error
}
// PlanRepository defines the interface for training plan storage operations
type PlanRepository interface {
List(ctx context.Context) ([]models.TrainingPlan, error)
GetByID(ctx context.Context, id int64) (*models.TrainingPlan, error)
Create(ctx context.Context, req *models.CreatePlanRequest) (*models.TrainingPlan, error)
Update(ctx context.Context, id int64, req *models.CreatePlanRequest) (*models.TrainingPlan, error)
Delete(ctx context.Context, id int64) error
}
// SessionRepository defines the interface for session storage operations
type SessionRepository interface {
List(ctx context.Context) ([]models.Session, error)
GetByID(ctx context.Context, id int64) (*models.Session, error)
Create(ctx context.Context, req *models.CreateSessionRequest) (*models.Session, error)
Update(ctx context.Context, id int64, req *models.CreateSessionRequest) (*models.Session, error)
Delete(ctx context.Context, id int64) error
AddEntry(ctx context.Context, sessionID int64, req *models.CreateSessionEntryRequest) (*models.SessionEntry, error)
}