Search in sources :

Example 1 with PageableSearchDTO

use of de.tum.in.www1.artemis.web.rest.dto.PageableSearchDTO in project ArTEMiS by ls1intum.

the class UserResource method getAllUsers.

/**
 * GET users : get all users.
 *
 * @param userSearch the pagination information for user search
 * @return the ResponseEntity with status 200 (OK) and with body all users
 */
@GetMapping("users")
@PreAuthorize("hasRole('ADMIN')")
public ResponseEntity<List<UserDTO>> getAllUsers(@ApiParam PageableSearchDTO<String> userSearch) {
    final Page<UserDTO> page = userRepository.getAllManagedUsers(userSearch);
    HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page);
    return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) UserDTO(de.tum.in.www1.artemis.service.dto.UserDTO) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 2 with PageableSearchDTO

use of de.tum.in.www1.artemis.web.rest.dto.PageableSearchDTO in project Artemis by ls1intum.

the class UserResource method getAllUsers.

/**
 * GET users : get all users.
 *
 * @param userSearch the pagination information for user search
 * @return the ResponseEntity with status 200 (OK) and with body all users
 */
@GetMapping("users")
@PreAuthorize("hasRole('ADMIN')")
public ResponseEntity<List<UserDTO>> getAllUsers(@ApiParam PageableSearchDTO<String> userSearch) {
    final Page<UserDTO> page = userRepository.getAllManagedUsers(userSearch);
    HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page);
    return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) UserDTO(de.tum.in.www1.artemis.service.dto.UserDTO) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

UserDTO (de.tum.in.www1.artemis.service.dto.UserDTO)2 HttpHeaders (org.springframework.http.HttpHeaders)2 ResponseEntity (org.springframework.http.ResponseEntity)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2