Merge remote-tracking branch 'origin/main'

This commit is contained in:
tuanvu
2026-01-09 10:46:16 +01:00
2 changed files with 6 additions and 5 deletions

View File

@@ -9,7 +9,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@@ -52,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.CONFLICT).body(mapToDTO(athleteDAO.findByKeycloakId(athlete.getKeycloakId()).get())); return ResponseEntity.status(200).body(mapToDTO(athleteDAO.findByKeycloakId(athlete.getKeycloakId()).get()));
} }
athleteDAO.save(athlete); athleteDAO.save(athlete);
return ResponseEntity.status(HttpStatus.CREATED).body(mapToDTO(athlete)); return ResponseEntity.status(201).body(mapToDTO(athlete));
} }
@Operation(summary = "Récupère tous les athlètes") @Operation(summary = "Récupère tous les athlètes")
@@ -282,4 +281,6 @@ public class AthleteResource {
} }
return new ArrayList<>(); return new ArrayList<>();
} }
} }

View File

@@ -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.CONFLICT).body(mapToDTO(coachDAO.findByKeycloakId(coach.getKeycloakId()).get())); return ResponseEntity.status(200).body(mapToDTO(coachDAO.findByKeycloakId(coach.getKeycloakId()).get()));
} }
coachDAO.save(coach); coachDAO.save(coach);
return ResponseEntity.status(HttpStatus.CREATED).body(mapToDTO(coach)); return ResponseEntity.status(201).body(mapToDTO(coach));
} }
@GetMapping("/all") @GetMapping("/all")