students endpoint

This commit is contained in:
Filip Izydorczyk
2020-12-07 22:21:34 +01:00
parent 82200acc06
commit 48394d3583
2 changed files with 47 additions and 5 deletions

View File

@ -36,10 +36,19 @@ public class UsersController {
@GetMapping("/student/search")
@PreAuthorize("hasRole('ROLE_DEANERY')")
@ApiOperation(value = "Serch for user by providing query. If query is empty it will return all students. You need token with DEANERY role to call this")
public ResponseEntity<List<UserResponse>> configApp(
public ResponseEntity<List<UserResponse>> searchForStudent(
@RequestParam("query") @ApiParam(value = "Query to filter all students. If empty will match everyone") String query) {
final List<User> searches = this.userService.searchForStudents(query);
final List<UserResponse> response = UserResponseMappers.mapToDefaultResponse(searches);
return new ResponseEntity<>(response, HttpStatus.OK);
}
@GetMapping("/students")
@PreAuthorize("hasRole('ROLE_DEANERY')")
@ApiOperation(value = "Gets all students. You need token with DEANERY role to call this")
public ResponseEntity<List<UserResponse>> getAllStudents() {
final List<User> searches = this.userService.searchForStudents("");
final List<UserResponse> response = UserResponseMappers.mapToDefaultResponse(searches);
return new ResponseEntity<>(response, HttpStatus.OK);
}
}