modified: serv_nginx/api_bb/internal/handlers/handlers.go

new file:   serv_nginx/api_bb/internal/handlers/user_workout_handler.go
	modified:   serv_nginx/api_bb/internal/models/workout.go
	modified:   serv_nginx/api_bb/internal/repository/workout_repository.go
	modified:   serv_nginx/api_bb/internal/routes/routes.go
	new file:   serv_nginx/api_bb/internal/service/user_workout_service.go
	new file:   serv_nginx/api_bb/pkg/utils/response.go
	new file:   serv_nginx/api_bb/pkg/utils/validation.go
add workout EndPoints for workout struct, CRUD operations and logics
This commit is contained in:
2025-10-19 08:20:21 +05:00
parent 15c59b2f55
commit 6c02f11570
8 changed files with 1077 additions and 9 deletions
+9 -9
View File
@@ -56,20 +56,20 @@ type WorkoutCreateRequest struct {
Type WorkoutType `json:"type" validate:"required,oneof=easy tempo interval long recovery"`
Distance float64 `json:"distance_km" validate:"required,min=0.1,max=1000"`
Duration int `json:"duration_min" validate:"required,min=1,max=1440"`
Pace string `json:"pace" validate:"max=20"`
Calories int `json:"calories" validate:"min=0,max=5000"`
Notes string `json:"notes" validate:"max=1000"`
Pace string `json:"pace" validate:"maxlen=20"`
Calories int `json:"calories" validate:"minint=0,maxint=5000"`
Notes string `json:"notes" validate:"maxlen=1000"`
Date time.Time `json:"date" validate:"required"`
}
// DTO для обновления тренировки
type WorkoutUpdateRequest struct {
Type WorkoutType `json:"type" validate:"omitempty,oneof=easy tempo interval long recovery"`
Distance float64 `json:"distance_km" validate:"omitempty,min=0.1,max=1000"`
Duration int `json:"duration_min" validate:"omitempty,min=1,max=1440"`
Pace string `json:"pace" validate:"omitempty,max=20"`
Calories int `json:"calories" validate:"omitempty,min=0,max=5000"`
Notes string `json:"notes" validate:"omitempty,max=1000"`
Type WorkoutType `json:"type" validate:"oneof=easy tempo interval long recovery"`
Distance float64 `json:"distance_km" validate:"min=0.1,max=1000"`
Duration int `json:"duration_min" validate:"min=1,max=1440"`
Pace string `json:"pace" validate:"maxlen=20"`
Calories int `json:"calories" validate:"minint=0,maxint=5000"`
Notes string `json:"notes" validate:"maxlen=1000"`
Date time.Time `json:"date"`
}