Skip to content

Commit 20f8709

Browse files
committed
Updated ParentController, ParentServiceImpl, and StudentServiceImpl with new methods.
1 parent 9d34c75 commit 20f8709

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

BackEnd/No-Country-simulation/src/main/java/com/school/rest/controller/NotificationController.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import com.school.persistence.entities.Student;
55
import com.school.persistence.repository.NotificationRepository;
66
import com.school.persistence.repository.StudentRepository;
7+
import com.school.rest.response.StudentResponse;
78
import com.school.service.dto.NotificationDTO;
9+
import com.school.service.implementation.ParentServiceImpl;
810
import com.school.service.interfaces.INotificationService;
911
import com.school.utility.NotificationMapper;
1012
import jakarta.persistence.EntityNotFoundException;
@@ -26,6 +28,8 @@
2628
@RestController
2729
@RequestMapping("/notifications")
2830
public class NotificationController {
31+
private final ParentServiceImpl parentService;
32+
2933
// Inyecta el servicio de notificaciones que maneja la lógica de negocio.
3034
@Autowired
3135
private INotificationService notificationService;
@@ -42,6 +46,10 @@ public class NotificationController {
4246
@Autowired
4347
private StudentRepository studentRepository;
4448

49+
public NotificationController(ParentServiceImpl parentService) {
50+
this.parentService = parentService;
51+
}
52+
4553
/**
4654
* Este método permite a los profesores enviar una notificación a todos los estudiantes y padres
4755
* de un curso específico. Se asegura que el usuario tenga el rol de profesor.
@@ -204,4 +212,9 @@ public ResponseEntity<String> respondToNotification(@PathVariable Long id, @Requ
204212
return ResponseEntity.ok("Respuesta añadida a la notificación.");
205213
}
206214

215+
@GetMapping("/verify/{dni}")
216+
public ResponseEntity<StudentResponse> getStudentAndParentByDni(@PathVariable String dni) {
217+
return ResponseEntity.ok(parentService.getStudentAndParentByDni(dni));
218+
}
219+
207220
}

BackEnd/No-Country-simulation/src/main/java/com/school/security/config/SecurityConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws
6060
http.requestMatchers(HttpMethod.GET, "/teacher/verifyStudent/**").hasAuthority("READ_PRIVILEGES");
6161
http.requestMatchers(HttpMethod.GET, "/admin/**").hasRole("ADMIN");
6262
http.requestMatchers(HttpMethod.GET, "/api/v1/status/auth-student").hasAnyRole("STUDENT");
63-
http.requestMatchers(HttpMethod.GET, "/api/v1/status/auth-teacher", "/admin/parent/verify/{dni}").hasAnyRole("TEACHER");
63+
http.requestMatchers(HttpMethod.GET, "/api/v1/status/auth-teacher", "/notifications/verify/{dni}").hasAnyRole("TEACHER");
6464
http.requestMatchers(HttpMethod.GET, "/api/v1/status/auth-parent").hasAnyRole("PARENT");
6565

6666
// Permisos para evaluaciones

0 commit comments

Comments
 (0)