89.1. Test list - pagination. return list (#10)

This commit is contained in:
Art
2021-09-11 00:25:41 +03:00
parent 5f34dc93c0
commit f9c8212bf7
3 changed files with 8 additions and 5 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.Pageable;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.AuthenticationManager;
@ -79,8 +80,8 @@ public class UserResource {
}
@GetMapping
public List<User> getAllUsers() {
return userService.findAll();
public List<User> getAllUsers(Pageable pageable) {
return userService.findAll(pageable);
}
@PostMapping("/resetPassword/{email}")

View File

@ -2,6 +2,7 @@ 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.Pageable;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.web.multipart.MultipartFile;
@ -12,7 +13,7 @@ public interface UserService extends UserDetailsService {
User register(String firstName, String lastName, String username, String email);
List<User> findAll();
List<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.Pageable;
import org.springframework.http.MediaType;
import org.springframework.http.RequestEntity;
import org.springframework.security.core.userdetails.UserDetails;
@ -126,8 +127,8 @@ public class UserServiceImpl implements UserService {
}
@Override
public List<User> findAll() {
return userRepository.findAll();
public List<User> findAll(Pageable pageable) {
return userRepository.findAll(pageable).getContent();
}
@Override