diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java index bcc866f..aee09b6 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java @@ -83,7 +83,6 @@ public class UserController { @GetMapping("/teachers") public ResponseEntity>> getAllTeachers(@RequestHeader("Authorization") String token){ - if (authServ.getUserFromToken(token) == null) return new UnauthorizedResponse<>(null); @@ -91,5 +90,15 @@ public class UserController { return new ResponseEntity<>(ProtectionService.usersWithoutPasswords(teachers), HttpStatus.OK); } -} + + @GetMapping("/students") + public ResponseEntity>> getAllStudent(@RequestHeader("Authorization") String token){ + if (authServ.getUserFromToken(token) == null) + return new UnauthorizedResponse<>(null); + + Iterable students = userService.getAllStudents(); + + return new ResponseEntity<>(ProtectionService.usersWithoutPasswords(students), HttpStatus.OK); + } +} \ No newline at end of file diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/UserRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/UserRepository.java index 2df4919..a275948 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Repositories/UserRepository.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/UserRepository.java @@ -12,4 +12,7 @@ public interface UserRepository extends CrudRepository { @Query("select u from User u where u.role = ovh.herisson.Clyde.Tables.Role.Teacher") Iterable findAllTeachers(); + + @Query("select u from User u where u.role = ovh.herisson.Clyde.Tables.Role.Student") + Iterable findAllStudents(); } \ No newline at end of file diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/UserService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/UserService.java index 56f3abe..52078dc 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/UserService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/UserService.java @@ -115,6 +115,7 @@ public class UserService { } - public Iterable getAllTeachers (){return userRepo.findAllTeachers();} + + public Iterable getAllStudents(){return userRepo.findAllStudents();} } \ No newline at end of file