Files
krafttrainer/backend/internal/model/training_set.go
Christoph K. dfd66e43c6 Initial commit
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-21 15:03:55 +01:00

53 lines
1.4 KiB
Go
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package model
import (
"errors"
"strings"
"time"
)
// TrainingSet ist eine benannte Zusammenstellung von Übungen.
type TrainingSet struct {
ID int64 `json:"id"`
Name string `json:"name"`
Exercises []Exercise `json:"exercises"`
CreatedAt time.Time `json:"created_at"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
}
// CreateSetRequest enthält die Felder zum Anlegen eines Sets.
type CreateSetRequest struct {
Name string `json:"name"`
ExerciseIDs []int64 `json:"exercise_ids"`
}
// Validate prüft und normalisiert den Request.
func (r *CreateSetRequest) Validate() error {
r.Name = strings.TrimSpace(r.Name)
if len(r.Name) == 0 || len(r.Name) > 100 {
return errors.New("Name muss 1100 Zeichen lang sein")
}
if len(r.ExerciseIDs) == 0 {
return errors.New("Mindestens eine Übung erforderlich")
}
return nil
}
// UpdateSetRequest enthält die Felder zum Aktualisieren eines Sets.
type UpdateSetRequest struct {
Name string `json:"name"`
ExerciseIDs []int64 `json:"exercise_ids"`
}
// Validate prüft und normalisiert den Request.
func (r *UpdateSetRequest) Validate() error {
r.Name = strings.TrimSpace(r.Name)
if len(r.Name) == 0 || len(r.Name) > 100 {
return errors.New("Name muss 1100 Zeichen lang sein")
}
if len(r.ExerciseIDs) == 0 {
return errors.New("Mindestens eine Übung erforderlich")
}
return nil
}