@@ -63,7 +63,7 @@ public ResponseEntity<List<HealthProfileResponseDTO>> getAllHealthProfiles() {
6363 }
6464
6565 @ GetMapping ("/{id}" )
66- @ PreAuthorize ("hasRole('Admin') or hasRole('Nutricionista') or @authService.isOwnerOrAdmin (#id)" )
66+ @ PreAuthorize ("hasRole('Admin') or hasRole('Nutricionista') or @authService.isOwnerOfProfile (#id)" )
6767 @ Operation (summary = "Buscar perfil por ID" , description = "Retorna um perfil de saúde específico pelo seu ID" )
6868 @ SecurityRequirement (name = "Bearer Authentication" )
6969 @ ApiResponses (value = {
@@ -165,7 +165,7 @@ public ResponseEntity<HealthProfileResponseDTO> createHealthProfile(
165165 }
166166
167167 @ PutMapping ("/{id}" )
168- @ PreAuthorize ("hasRole('Admin') or hasRole('Nutricionista') or @authService.isOwnerOrAdmin (#id)" )
168+ @ PreAuthorize ("hasRole('Admin') or hasRole('Nutricionista') or @authService.isOwnerOfProfile (#id)" )
169169 @ Operation (summary = "Atualizar perfil por ID" , description = "Atualiza um perfil de saúde pelo seu ID" )
170170 @ SecurityRequirement (name = "Bearer Authentication" )
171171 public ResponseEntity <HealthProfileResponseDTO > updateHealthProfile (
@@ -347,56 +347,57 @@ public ResponseEntity<Void> removeDiseaseFromProfile(@PathVariable Long profileI
347347 }
348348
349349 @ PostMapping ("/{profileId}/allergies/{allergyId}" )
350- @ PreAuthorize ("isAuthenticated( )" )
351- @ Operation (summary = "Adicionar alergia a um perfil" )
350+ @ PreAuthorize ("hasRole('Admin') or @authService.isOwnerOfProfile(#profileId )" )
351+ @ Operation (summary = "Adicionar alergia a um perfil" , description = "Associa uma alergia existente a um perfil de saúde" )
352352 @ SecurityRequirement (name = "Bearer Authentication" )
353353 public ResponseEntity <Void > addAllergyToProfile (@ PathVariable Long profileId , @ PathVariable Long allergyId ) {
354354 healthProfileService .addAllergyToProfile (profileId , allergyId );
355355 return ResponseEntity .ok ().build ();
356356 }
357357
358358 @ DeleteMapping ("/{profileId}/allergies/{allergyId}" )
359- @ PreAuthorize ("isAuthenticated( )" )
360- @ Operation (summary = "Remover alergia de um perfil" )
359+ @ PreAuthorize ("hasRole('Admin') or @authService.isOwnerOfProfile(#profileId )" )
360+ @ Operation (summary = "Remover alergia de um perfil" , description = "Desassocia uma alergia de um perfil de saúde" )
361361 @ SecurityRequirement (name = "Bearer Authentication" )
362362 public ResponseEntity <Void > removeAllergyFromProfile (@ PathVariable Long profileId , @ PathVariable Long allergyId ) {
363363 healthProfileService .removeAllergyFromProfile (profileId , allergyId );
364364 return ResponseEntity .noContent ().build ();
365365 }
366366
367+ // Endpoints para Intolerâncias
367368 @ PostMapping ("/{profileId}/intolerances/{intoleranceId}" )
368- @ PreAuthorize ("isAuthenticated( )" )
369- @ Operation (summary = "Adicionar intolerância a um perfil" )
369+ @ PreAuthorize ("hasRole('Admin') or @authService.isOwnerOfProfile(#profileId )" )
370+ @ Operation (summary = "Adicionar intolerância a um perfil" , description = "Associa uma intolerância existente a um perfil de saúde" )
370371 @ SecurityRequirement (name = "Bearer Authentication" )
371372 public ResponseEntity <Void > addIntoleranceToProfile (@ PathVariable Long profileId , @ PathVariable Long intoleranceId ) {
372373 healthProfileService .addIntoleranceToProfile (profileId , intoleranceId );
373374 return ResponseEntity .ok ().build ();
374375 }
375376
376377 @ DeleteMapping ("/{profileId}/intolerances/{intoleranceId}" )
377- @ PreAuthorize ("isAuthenticated( )" )
378- @ Operation (summary = "Remover intolerância de um perfil" )
378+ @ PreAuthorize ("hasRole('Admin') or @authService.isOwnerOfProfile(#profileId )" )
379+ @ Operation (summary = "Remover intolerância de um perfil" , description = "Desassocia uma intolerância de um perfil de saúde" )
379380 @ SecurityRequirement (name = "Bearer Authentication" )
380381 public ResponseEntity <Void > removeIntoleranceFromProfile (@ PathVariable Long profileId , @ PathVariable Long intoleranceId ) {
381382 healthProfileService .removeIntoleranceFromProfile (profileId , intoleranceId );
382383 return ResponseEntity .noContent ().build ();
383384 }
384385
385- @ PostMapping ("/{profileId}/dietary-preferences/{preferenceId }" )
386- @ PreAuthorize ("isAuthenticated( )" )
387- @ Operation (summary = "Adicionar preferência alimentar a um perfil" )
386+ @ PostMapping ("/{profileId}/dietary-preferences/{dietaryPreferenceId }" )
387+ @ PreAuthorize ("hasRole('Admin') or @authService.isOwnerOfProfile(#profileId )" )
388+ @ Operation (summary = "Adicionar preferência alimentar a um perfil" , description = "Associa uma preferência alimentar existente a um perfil de saúde" )
388389 @ SecurityRequirement (name = "Bearer Authentication" )
389- public ResponseEntity <Void > addDietaryPreferenceToProfile (@ PathVariable Long profileId , @ PathVariable Long preferenceId ) {
390- healthProfileService .addDietaryPreferenceToProfile (profileId , preferenceId );
390+ public ResponseEntity <Void > addDietaryPreferenceToProfile (@ PathVariable Long profileId , @ PathVariable Long dietaryPreferenceId ) {
391+ healthProfileService .addDietaryPreferenceToProfile (profileId , dietaryPreferenceId );
391392 return ResponseEntity .ok ().build ();
392393 }
393394
394- @ DeleteMapping ("/{profileId}/dietary-preferences/{preferenceId }" )
395- @ PreAuthorize ("isAuthenticated( )" )
396- @ Operation (summary = "Remover preferência alimentar de um perfil" )
395+ @ DeleteMapping ("/{profileId}/dietary-preferences/{dietaryPreferenceId }" )
396+ @ PreAuthorize ("hasRole('Admin') or @authService.isOwnerOfProfile(#profileId )" )
397+ @ Operation (summary = "Remover preferência alimentar de um perfil" , description = "Desassocia uma preferência alimentar de um perfil de saúde" )
397398 @ SecurityRequirement (name = "Bearer Authentication" )
398- public ResponseEntity <Void > removeDietaryPreferenceFromProfile (@ PathVariable Long profileId , @ PathVariable Long preferenceId ) {
399- healthProfileService .removeDietaryPreferenceFromProfile (profileId , preferenceId );
399+ public ResponseEntity <Void > removeDietaryPreferenceFromProfile (@ PathVariable Long profileId , @ PathVariable Long dietaryPreferenceId ) {
400+ healthProfileService .removeDietaryPreferenceFromProfile (profileId , dietaryPreferenceId );
400401 return ResponseEntity .noContent ().build ();
401402 }
402403}
0 commit comments