diff --git a/.github/workflows/CI-CD-Test.yml b/.github/workflows/CI-CD-Test.yml
index 91fe77e..b182e6d 100644
--- a/.github/workflows/CI-CD-Test.yml
+++ b/.github/workflows/CI-CD-Test.yml
@@ -46,6 +46,7 @@ jobs:
echo "Ejecutando test: Dado que no hay ninguna reserva registrada, Cuándo lo creo a nivel de servicio, Entonces la creación será exitosa."
echo "Ejecutando test: Dado que tengo 1 reserva registrada, Cuándo la elimino a nivel de servicio, Entonces la eliminación será exitosa."
echo "Ejecutando test: Dado que tengo 1 reserva registrada, Cuándo la elimino y consulto a nivel de servicio, Entonces el resultado de la consulta no retornará ningún resultado."
+
deploy:
name: Deploy
needs: test
diff --git a/.gitignore b/.gitignore
index 062bad1..2021304 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,3 +34,4 @@ build/
.env
errorLog.txt
requirements.pdf
+4_Maven Verify.txt
diff --git a/pom.xml b/pom.xml
index ce05308..9a40eeb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -170,6 +170,8 @@
dotenv-java
2.3.1
+
+
diff --git a/src/main/java/edu/eci/cvds/prometeo/controller/UserController.java b/src/main/java/edu/eci/cvds/prometeo/controller/UserController.java
index dbb9478..9d2b40e 100644
--- a/src/main/java/edu/eci/cvds/prometeo/controller/UserController.java
+++ b/src/main/java/edu/eci/cvds/prometeo/controller/UserController.java
@@ -62,7 +62,6 @@ public class UserController {
@Autowired
private UserService userService;
-
@Autowired
private GymReservationService gymReservationService;
@@ -267,14 +266,14 @@ public ResponseEntity updatePhysicalMeasurements(
@Parameter(description = "Progress ID") @PathVariable UUID progressId,
@RequestBody BodyMeasurementsDTO measurementsDTO) {
- // Convertir DTO a entidad
- BodyMeasurements measurements = new BodyMeasurements();
- measurements.setHeight(measurementsDTO.getHeight());
- measurements.setChestCircumference(measurementsDTO.getChestCircumference());
- measurements.setWaistCircumference(measurementsDTO.getWaistCircumference());
- measurements.setHipCircumference(measurementsDTO.getHipCircumference());
- measurements.setBicepsCircumference(measurementsDTO.getBicepsCircumference());
- measurements.setThighCircumference(measurementsDTO.getThighCircumference());
+ // Convertir DTO a entidad
+ BodyMeasurements measurements = new BodyMeasurements();
+ measurements.setHeight(measurementsDTO.getHeight());
+ measurements.setChestCircumference(measurementsDTO.getChestCircumference());
+ measurements.setWaistCircumference(measurementsDTO.getWaistCircumference());
+ measurements.setHipCircumference(measurementsDTO.getHipCircumference());
+ measurements.setBicepsCircumference(measurementsDTO.getBicepsCircumference());
+ measurements.setThighCircumference(measurementsDTO.getThighCircumference());
PhysicalProgress updatedProgress = userService.updatePhysicalMeasurement(progressId, measurements);
return ResponseEntity.ok(updatedProgress);
}
@@ -327,145 +326,145 @@ public ResponseEntity> getTraineePhysicalProgress(
return ResponseEntity.ok(history);
}
// -----------------------------------------------------
-// Routine management endpoints
-// -----------------------------------------------------
-
-@GetMapping("/{userId}/routines")
-@Operation(summary = "Get user routines", description = "Retrieves all routines assigned to a user")
-@ApiResponse(responseCode = "200", description = "Routines retrieved successfully")
-@ApiResponse(responseCode = "404", description = "User not found")
-public ResponseEntity> getUserRoutines(
- @Parameter(description = "User ID") @PathVariable UUID userId) {
-
- List routines = userService.getUserRoutines(userId);
- return ResponseEntity.ok(routines);
-}
+ // Routine management endpoints
+ // -----------------------------------------------------
-@GetMapping("/{userId}/routines/current")
-@Operation(summary = "Get current routine", description = "Retrieves the user's current active routine")
-@ApiResponse(responseCode = "200", description = "Routine retrieved successfully")
-@ApiResponse(responseCode = "404", description = "No active routine found")
-public ResponseEntity getCurrentRoutine(
- @Parameter(description = "User ID") @PathVariable UUID userId) {
- // TODO: Move this logic to userservice layer
- return routineRepository.findCurrentRoutineByUserId(userId)
- .map(routine -> ResponseEntity.ok(routine))
- .orElse(ResponseEntity.notFound().build());
-}
+ @GetMapping("/{userId}/routines")
+ @Operation(summary = "Get user routines", description = "Retrieves all routines assigned to a user")
+ @ApiResponse(responseCode = "200", description = "Routines retrieved successfully")
+ @ApiResponse(responseCode = "404", description = "User not found")
+ public ResponseEntity> getUserRoutines(
+ @Parameter(description = "User ID") @PathVariable UUID userId) {
-@PostMapping("/{userId}/routines/assign/{routineId}")
-@Operation(summary = "Assign routine to user", description = "Assigns an existing routine to a user")
-@ApiResponse(responseCode = "204", description = "Routine assigned successfully")
-@ApiResponse(responseCode = "404", description = "User or routine not found")
-public ResponseEntity assignRoutineToUser(
- @Parameter(description = "User ID") @PathVariable UUID userId,
- @Parameter(description = "Routine ID") @PathVariable UUID routineId) {
+ List routines = userService.getUserRoutines(userId);
+ return ResponseEntity.ok(routines);
+ }
- userService.assignRoutineToUser(userId, routineId);
- return ResponseEntity.noContent().build();
-}
+ @GetMapping("/{userId}/routines/current")
+ @Operation(summary = "Get current routine", description = "Retrieves the user's current active routine")
+ @ApiResponse(responseCode = "200", description = "Routine retrieved successfully")
+ @ApiResponse(responseCode = "404", description = "No active routine found")
+ public ResponseEntity getCurrentRoutine(
+ @Parameter(description = "User ID") @PathVariable UUID userId) {
+ // TODO: Move this logic to userservice layer
+ return routineRepository.findCurrentRoutineByUserId(userId)
+ .map(routine -> ResponseEntity.ok(routine))
+ .orElse(ResponseEntity.notFound().build());
+ }
-@PostMapping("/{userId}/routines/custom")
-@Operation(summary = "Create custom routine", description = "Creates a custom routine for a user")
-@ApiResponse(responseCode = "201", description = "Routine created successfully")
-@ApiResponse(responseCode = "404", description = "User not found")
-public ResponseEntity createCustomRoutine(
- @Parameter(description = "User ID") @PathVariable UUID userId,
- @Parameter(description = "Routine data") @RequestBody RoutineDTO routineDTO) {
-
- // Convertir DTO a entidad
- Routine routine = new Routine();
- routine.setName(routineDTO.getName());
- routine.setDescription(routineDTO.getDescription());
- routine.setDifficulty(routineDTO.getDifficulty());
- routine.setGoal(routineDTO.getGoal());
- routine.setCreationDate(LocalDate.now());
-
- // Crear una lista vacía de ejercicios desde el principio
- routine.setExercises(new ArrayList<>());
-
- // Crear primero la rutina con la lista vacía
- Routine createdRoutine = userService.createCustomRoutine(userId, routine);
-
- // Ahora que la rutina tiene un ID, añadir los ejercicios uno por uno
- if (routineDTO.getExercises() != null && !routineDTO.getExercises().isEmpty()) {
- // Usar un enfoque de servicio para añadir cada ejercicio individualmente
- for (RoutineExerciseDTO exerciseDTO : routineDTO.getExercises()) {
- RoutineExercise exercise = new RoutineExercise();
- exercise.setBaseExerciseId(exerciseDTO.getBaseExerciseId());
- exercise.setRoutineId(createdRoutine.getId());
- exercise.setSets(exerciseDTO.getSets());
- exercise.setRepetitions(exerciseDTO.getRepetitions());
- exercise.setRestTime(exerciseDTO.getRestTime());
- exercise.setSequenceOrder(exerciseDTO.getSequenceOrder());
-
- // Añadir a la base de datos directamente sin pasar por la colección de la rutina
- routineExerciseRepository.save(exercise);
- }
+ @PostMapping("/{userId}/routines/assign/{routineId}")
+ @Operation(summary = "Assign routine to user", description = "Assigns an existing routine to a user")
+ @ApiResponse(responseCode = "204", description = "Routine assigned successfully")
+ @ApiResponse(responseCode = "404", description = "User or routine not found")
+ public ResponseEntity assignRoutineToUser(
+ @Parameter(description = "User ID") @PathVariable UUID userId,
+ @Parameter(description = "Routine ID") @PathVariable UUID routineId) {
+
+ userService.assignRoutineToUser(userId, routineId);
+ return ResponseEntity.noContent().build();
}
- // Recargar la rutina para obtener todos los ejercicios asociados
- return new ResponseEntity<>(
- routineRepository.findById(createdRoutine.getId())
- .orElseThrow(() -> new RuntimeException("Failed to find newly created routine")),
- HttpStatus.CREATED
- );
-}
+ @PostMapping("/{userId}/routines/custom")
+ @Operation(summary = "Create custom routine", description = "Creates a custom routine for a user")
+ @ApiResponse(responseCode = "201", description = "Routine created successfully")
+ @ApiResponse(responseCode = "404", description = "User not found")
+ public ResponseEntity createCustomRoutine(
+ @Parameter(description = "User ID") @PathVariable UUID userId,
+ @Parameter(description = "Routine data") @RequestBody RoutineDTO routineDTO) {
-@PutMapping("/routines/{routineId}")
-@Operation(summary = "Update routine", description = "Updates an existing routine")
-@ApiResponse(responseCode = "200", description = "Routine updated successfully")
-@ApiResponse(responseCode = "404", description = "Routine not found")
-public ResponseEntity updateRoutine(
- @Parameter(description = "Routine ID") @PathVariable UUID routineId,
- @Parameter(description = "Updated routine data") @RequestBody RoutineDTO routineDTO) {
- // TODO: Move this logic to userservice layer
- // Buscar la rutina existente
- Routine existingRoutine = routineRepository.findById(routineId)
- .orElseThrow(() -> new RuntimeException("Routine not found"));
-
- // Actualizar campos
- existingRoutine.setName(routineDTO.getName());
- existingRoutine.setDescription(routineDTO.getDescription());
- existingRoutine.setDifficulty(routineDTO.getDifficulty());
- existingRoutine.setGoal(routineDTO.getGoal());
-
- // Actualizar la rutina
- Routine updatedRoutine = userService.updateRoutine(routineId, existingRoutine);
- return ResponseEntity.ok(updatedRoutine);
-}
+ // Convertir DTO a entidad
+ Routine routine = new Routine();
+ routine.setName(routineDTO.getName());
+ routine.setDescription(routineDTO.getDescription());
+ routine.setDifficulty(routineDTO.getDifficulty());
+ routine.setGoal(routineDTO.getGoal());
+ routine.setCreationDate(LocalDate.now());
+
+ // Crear una lista vacía de ejercicios desde el principio
+ routine.setExercises(new ArrayList<>());
+
+ // Crear primero la rutina con la lista vacía
+ Routine createdRoutine = userService.createCustomRoutine(userId, routine);
+
+ // Ahora que la rutina tiene un ID, añadir los ejercicios uno por uno
+ if (routineDTO.getExercises() != null && !routineDTO.getExercises().isEmpty()) {
+ // Usar un enfoque de servicio para añadir cada ejercicio individualmente
+ for (RoutineExerciseDTO exerciseDTO : routineDTO.getExercises()) {
+ RoutineExercise exercise = new RoutineExercise();
+ exercise.setBaseExerciseId(exerciseDTO.getBaseExerciseId());
+ exercise.setRoutineId(createdRoutine.getId());
+ exercise.setSets(exerciseDTO.getSets());
+ exercise.setRepetitions(exerciseDTO.getRepetitions());
+ exercise.setRestTime(exerciseDTO.getRestTime());
+ exercise.setSequenceOrder(exerciseDTO.getSequenceOrder());
+
+ // Añadir a la base de datos directamente sin pasar por la colección de la
+ // rutina
+ routineExerciseRepository.save(exercise);
+ }
+ }
-@PostMapping("/{userId}/routines/{routineId}/progress")
-@Operation(summary = "Log routine progress", description = "Records progress for a routine session")
-@ApiResponse(responseCode = "204", description = "Progress logged successfully")
-@ApiResponse(responseCode = "404", description = "User or routine not found")
-public ResponseEntity logRoutineProgress(
- @Parameter(description = "User ID") @PathVariable UUID userId,
- @Parameter(description = "Routine ID") @PathVariable UUID routineId,
- @Parameter(description = "Progress percentage") @RequestBody Map progressData) {
+ // Recargar la rutina para obtener todos los ejercicios asociados
+ return new ResponseEntity<>(
+ routineRepository.findById(createdRoutine.getId())
+ .orElseThrow(() -> new RuntimeException("Failed to find newly created routine")),
+ HttpStatus.CREATED);
+ }
- Integer completedPercentage = progressData.get("completed");
- if (completedPercentage == null) {
- completedPercentage = 100; // Valor por defecto si no se proporciona
+ @PutMapping("/routines/{routineId}")
+ @Operation(summary = "Update routine", description = "Updates an existing routine")
+ @ApiResponse(responseCode = "200", description = "Routine updated successfully")
+ @ApiResponse(responseCode = "404", description = "Routine not found")
+ public ResponseEntity updateRoutine(
+ @Parameter(description = "Routine ID") @PathVariable UUID routineId,
+ @Parameter(description = "Updated routine data") @RequestBody RoutineDTO routineDTO) {
+ // TODO: Move this logic to userservice layer
+ // Buscar la rutina existente
+ Routine existingRoutine = routineRepository.findById(routineId)
+ .orElseThrow(() -> new RuntimeException("Routine not found"));
+
+ // Actualizar campos
+ existingRoutine.setName(routineDTO.getName());
+ existingRoutine.setDescription(routineDTO.getDescription());
+ existingRoutine.setDifficulty(routineDTO.getDifficulty());
+ existingRoutine.setGoal(routineDTO.getGoal());
+
+ // Actualizar la rutina
+ Routine updatedRoutine = userService.updateRoutine(routineId, existingRoutine);
+ return ResponseEntity.ok(updatedRoutine);
}
- userService.logRoutineProgress(userId, routineId, completedPercentage);
- return ResponseEntity.noContent().build();
-}
+ @PostMapping("/{userId}/routines/{routineId}/progress")
+ @Operation(summary = "Log routine progress", description = "Records progress for a routine session")
+ @ApiResponse(responseCode = "204", description = "Progress logged successfully")
+ @ApiResponse(responseCode = "404", description = "User or routine not found")
+ public ResponseEntity logRoutineProgress(
+ @Parameter(description = "User ID") @PathVariable UUID userId,
+ @Parameter(description = "Routine ID") @PathVariable UUID routineId,
+ @Parameter(description = "Progress percentage") @RequestBody Map progressData) {
-@GetMapping("/{userId}/recommended-routines")
-@Operation(summary = "Get recommended routines", description = "Retrieves personalized routine recommendations for a user")
-@ApiResponse(responseCode = "200", description = "Recommendations retrieved successfully")
-@ApiResponse(responseCode = "404", description = "User not found")
-public ResponseEntity> getRecommendedRoutines(
- @Parameter(description = "User ID") @PathVariable UUID userId) {
+ Integer completedPercentage = progressData.get("completed");
+ if (completedPercentage == null) {
+ completedPercentage = 100; // Valor por defecto si no se proporciona
+ }
- List recommendations = userService.getRecommendedRoutines(userId);
- return ResponseEntity.ok(recommendations);
-}
+ userService.logRoutineProgress(userId, routineId, completedPercentage);
+ return ResponseEntity.noContent().build();
+ }
-// -------------------------- Exercise crud ---------
-@GetMapping("/exercises")
+ @GetMapping("/{userId}/recommended-routines")
+ @Operation(summary = "Get recommended routines", description = "Retrieves personalized routine recommendations for a user")
+ @ApiResponse(responseCode = "200", description = "Recommendations retrieved successfully")
+ @ApiResponse(responseCode = "404", description = "User not found")
+ public ResponseEntity> getRecommendedRoutines(
+ @Parameter(description = "User ID") @PathVariable UUID userId) {
+
+ List recommendations = userService.getRecommendedRoutines(userId);
+ return ResponseEntity.ok(recommendations);
+ }
+
+ // -------------------------- Exercise crud ---------
+ @GetMapping("/exercises")
@Operation(summary = "Get all exercises", description = "Retrieves all base exercises in the system")
@ApiResponse(responseCode = "200", description = "Exercises retrieved successfully")
public ResponseEntity> getAllExercises() {
@@ -544,347 +543,409 @@ public ResponseEntity deleteExercise(
}
// -----------------------------------------------------
-// Gym reservations endpoints
-// -----------------------------------------------------
-// TODO: implementar bien modulo, configurar endpoint para gestion de sesiones gym.
-
-@GetMapping("/gym/availability")
-@Operation(summary = "Get gym availability", description = "Retrieves gym availability for a specific date")
-@ApiResponse(responseCode = "200", description = "Availability information retrieved successfully")
-public ResponseEntity> getGymAvailability(
- @Parameter(description = "Date to check")
- @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date) {
- List