add getGroupe dans session et athlete
This commit is contained in:
@@ -208,6 +208,20 @@ public class AthleteResource {
|
||||
return athleteSessions;
|
||||
}
|
||||
|
||||
@GetMapping("/{athleteId}/groupes")
|
||||
public List<String> getGroupesByAthlete(@PathVariable Integer athleteId) {
|
||||
java.util.Optional<Athlete> athleteOptional = athleteDAO.findById(athleteId);
|
||||
List<String> groupes = new ArrayList<>();
|
||||
if (athleteOptional.isPresent()) {
|
||||
Athlete athlete = athleteOptional.get();
|
||||
for (Session session : athlete.getSessions()) {
|
||||
if (!groupes.contains(session.getGroupe())) {
|
||||
groupes.add(session.getGroupe());
|
||||
}
|
||||
}
|
||||
}
|
||||
return groupes;
|
||||
}
|
||||
|
||||
@Operation(summary = "Récupère toutes les sessions")
|
||||
@ApiResponses(value = {
|
||||
|
||||
@@ -124,6 +124,17 @@ public class SessionResource {
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("{id}/groupe")
|
||||
@PreAuthorize("hasRole('coach') or hasRole('athlete')")
|
||||
public ResponseEntity<?> getGroupeById(@PathVariable Integer id) {
|
||||
try {
|
||||
Session session = sessionDAO.findById(id).orElseThrow();
|
||||
return ResponseEntity.ok(session.getGroupe());
|
||||
} catch (Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
@PreAuthorize("hasRole('coach')")
|
||||
public ResponseEntity<Void> updateSession(@PathVariable Integer id, @RequestBody SessionDTO dto) {
|
||||
|
||||
Reference in New Issue
Block a user