|
@@ -4,6 +4,8 @@ import io.zipcoder.tc_spring_poll_application.domain.Poll;
|
4
|
4
|
import io.zipcoder.tc_spring_poll_application.exception.ResourceNotFoundException;
|
5
|
5
|
import io.zipcoder.tc_spring_poll_application.repositories.PollRepository;
|
6
|
6
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
7
|
+import org.springframework.data.domain.Page;
|
|
8
|
+import org.springframework.data.domain.Pageable;
|
7
|
9
|
import org.springframework.http.HttpHeaders;
|
8
|
10
|
import org.springframework.http.HttpStatus;
|
9
|
11
|
import org.springframework.http.ResponseEntity;
|
|
@@ -18,16 +20,14 @@ public class PollController {
|
18
|
20
|
|
19
|
21
|
private PollRepository pollRepository;
|
20
|
22
|
|
21
|
|
-
|
22
|
|
-
|
23
|
23
|
@Autowired
|
24
|
24
|
public PollController(PollRepository pollRepository) {
|
25
|
25
|
this.pollRepository = pollRepository;
|
26
|
26
|
}
|
27
|
27
|
|
28
|
28
|
@RequestMapping(value="/polls", method= RequestMethod.GET)
|
29
|
|
- public ResponseEntity<Iterable<Poll>> getAllPolls() {
|
30
|
|
- Iterable<Poll> allPolls = pollRepository.findAll();
|
|
29
|
+ public ResponseEntity<Page<Poll>> getAllPolls(Pageable pageable) {
|
|
30
|
+ Page<Poll> allPolls = pollRepository.findAll(pageable);
|
31
|
31
|
return new ResponseEntity<>(allPolls, HttpStatus.OK);
|
32
|
32
|
}
|
33
|
33
|
|