Skip to content

Commit

Permalink
chore : Renvoyer le body au post
Browse files Browse the repository at this point in the history
  • Loading branch information
aureliadelzottoOCTO committed Dec 5, 2024
1 parent b55665c commit 93ee396
Show file tree
Hide file tree
Showing 6 changed files with 259 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ class ProfilEleveController(
)
fun postProfilEleve(
@RequestBody modificationProfilDTO: ModificationProfilDTO,
): ResponseEntity<Unit> {
): ProfilDTO {
val eleve = recupererEleve()
miseAJourEleveService.mettreAJourUnProfilEleve(
miseAJourDuProfil = modificationProfilDTO.toModificationProfilEleve(),
profilActuel = eleve,
)
return ResponseEntity<Unit>(HttpStatus.NO_CONTENT)
val profilEleve =
miseAJourEleveService.mettreAJourUnProfilEleve(
miseAJourDuProfil = modificationProfilDTO.toModificationProfilEleve(),
profilActuel = eleve,
)
return ProfilDTO(profilEleve)
}

@GetMapping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ data class ProfilDTO(
@JsonProperty("voeuxFavoris")
val voeuxFavoris: List<VoeuFavoriDTO>? = null,
) {
constructor(profilEleve: ProfilEleve.AvecProfilExistant, voeuxFavoris: List<VoeuFavori>) : this(
constructor(profilEleve: ProfilEleve.AvecProfilExistant, voeuxFavoris: List<VoeuFavori>? = null) : this(
situation = profilEleve.situation,
classe = profilEleve.classe,
baccalaureat = profilEleve.baccalaureat,
Expand All @@ -121,7 +121,7 @@ data class ProfilDTO(
domaines = profilEleve.domainesInterets,
corbeilleFormations = profilEleve.corbeilleFormations,
compteParcoursupAssocie = profilEleve.compteParcoursupLie,
voeuxFavoris = voeuxFavoris.map { VoeuFavoriDTO(it) },
voeuxFavoris = (voeuxFavoris ?: profilEleve.voeuxFavoris).map { VoeuFavoriDTO(it) },
)

data class CommuneDTO(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MiseAJourEleveService(
fun mettreAJourUnProfilEleve(
miseAJourDuProfil: ModificationProfilEleve,
profilActuel: ProfilEleve,
) {
): ProfilEleve.AvecProfilExistant {
val profilInitial =
when (profilActuel) {
is ProfilEleve.SansCompte -> eleveRepository.creerUnEleve(profilActuel.id)
Expand Down Expand Up @@ -77,6 +77,9 @@ class MiseAJourEleveService(
)
if (profilEleveAMettreAJour != profilInitial) {
eleveRepository.mettreAJourUnProfilEleve(profilEleveAMettreAJour)
return profilEleveAMettreAJour
} else {
return profilInitial
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ abstract class ControllerTest {
}

companion object {
private const val ID_ELEVE = "adcf627c-36dd-4df5-897b-159443a6d49c"
const val ID_ELEVE = "adcf627c-36dd-4df5-897b-159443a6d49c"
const val ID_ENSEIGNANT = "49e8e8c2-5eec-4eae-a90d-992225bbea1b"

val unProfilEleve =
Expand Down
Loading

0 comments on commit 93ee396

Please sign in to comment.