89.2. Test list - pagination. return page (#10)

This commit is contained in:
Art
2021-09-11 00:43:56 +03:00
parent f9c8212bf7
commit 1d058a367c
4 changed files with 23 additions and 10 deletions

View File

@ -8,6 +8,7 @@ import net.shyshkin.study.fullstack.supportportal.backend.domain.User;
import net.shyshkin.study.fullstack.supportportal.backend.domain.dto.UserDto;
import net.shyshkin.study.fullstack.supportportal.backend.service.UserService;
import net.shyshkin.study.fullstack.supportportal.backend.utility.JwtTokenProvider;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
@ -20,7 +21,6 @@ import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import static org.springframework.http.HttpStatus.OK;
@ -80,7 +80,7 @@ public class UserResource {
}
@GetMapping
public List<User> getAllUsers(Pageable pageable) {
public Page<User> getAllUsers(Pageable pageable) {
return userService.findAll(pageable);
}

View File

@ -2,18 +2,18 @@ package net.shyshkin.study.fullstack.supportportal.backend.service;
import net.shyshkin.study.fullstack.supportportal.backend.domain.User;
import net.shyshkin.study.fullstack.supportportal.backend.domain.dto.UserDto;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
public interface UserService extends UserDetailsService {
User register(String firstName, String lastName, String username, String email);
List<User> findAll(Pageable pageable);
Page<User> findAll(Pageable pageable);
User findByUsername(String username);

View File

@ -15,6 +15,7 @@ import net.shyshkin.study.fullstack.supportportal.backend.repository.UserReposit
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.MediaType;
import org.springframework.http.RequestEntity;
@ -33,7 +34,6 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
@ -127,8 +127,8 @@ public class UserServiceImpl implements UserService {
}
@Override
public List<User> findAll(Pageable pageable) {
return userRepository.findAll(pageable).getContent();
public Page<User> findAll(Pageable pageable) {
return userRepository.findAll(pageable);
}
@Override