Changed HTTP codes on Coach and Athlete creation
This commit is contained in:
@@ -51,10 +51,10 @@ public class AthleteResource {
|
|||||||
public ResponseEntity<AthleteDTO> create(@RequestBody AthleteDTO dto) {
|
public ResponseEntity<AthleteDTO> create(@RequestBody AthleteDTO dto) {
|
||||||
Athlete athlete = mapToEntity(dto);
|
Athlete athlete = mapToEntity(dto);
|
||||||
if(athleteDAO.existsByKeycloakId(athlete.getKeycloakId())) {
|
if(athleteDAO.existsByKeycloakId(athlete.getKeycloakId())) {
|
||||||
return ResponseEntity.status(HttpStatus.FOUND).body(mapToDTO(athleteDAO.findByKeycloakId(athlete.getKeycloakId()).get()));
|
return ResponseEntity.status(201).body(mapToDTO(athleteDAO.findByKeycloakId(athlete.getKeycloakId()).get()));
|
||||||
}
|
}
|
||||||
athleteDAO.save(athlete);
|
athleteDAO.save(athlete);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(mapToDTO(athlete));
|
return ResponseEntity.status(200).body(mapToDTO(athlete));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "Récupère tous les athlètes")
|
@Operation(summary = "Récupère tous les athlètes")
|
||||||
@@ -163,7 +163,6 @@ public class AthleteResource {
|
|||||||
@ApiResponse(responseCode = "200", description = "Récupération effectuée", content = @Content(mediaType = "application/json", schema = @Schema(implementation = SessionDTO.class)))
|
@ApiResponse(responseCode = "200", description = "Récupération effectuée", content = @Content(mediaType = "application/json", schema = @Schema(implementation = SessionDTO.class)))
|
||||||
})
|
})
|
||||||
@GetMapping("/athlete/{id}/session")
|
@GetMapping("/athlete/{id}/session")
|
||||||
@PreAuthorize("hasRole('admin') or #id == principal.id")
|
|
||||||
public List<SessionDTO> getSessionsAthlete(@PathVariable Integer athleteId) {
|
public List<SessionDTO> getSessionsAthlete(@PathVariable Integer athleteId) {
|
||||||
// return pet
|
// return pet
|
||||||
System.out.println("ID A CHERCHER" + athleteId);
|
System.out.println("ID A CHERCHER" + athleteId);
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ public class CoachResource {
|
|||||||
public ResponseEntity<CoachDTO> create(@RequestBody CoachDTO dto) {
|
public ResponseEntity<CoachDTO> create(@RequestBody CoachDTO dto) {
|
||||||
Coach coach = mapToEntity(dto);
|
Coach coach = mapToEntity(dto);
|
||||||
if(coachDAO.existsByKeycloakId(coach.getKeycloakId())) {
|
if(coachDAO.existsByKeycloakId(coach.getKeycloakId())) {
|
||||||
return ResponseEntity.status(HttpStatus.FOUND).body(mapToDTO(coachDAO.findByKeycloakId(coach.getKeycloakId()).get()));
|
return ResponseEntity.status(201).body(mapToDTO(coachDAO.findByKeycloakId(coach.getKeycloakId()).get()));
|
||||||
}
|
}
|
||||||
coachDAO.save(coach);
|
coachDAO.save(coach);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(mapToDTO(coach));
|
return ResponseEntity.status(200).body(mapToDTO(coach));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
|
|||||||
Reference in New Issue
Block a user