|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+package io.zipcoder.tc_spring_poll_application.controller;
|
|
|
2
|
+
|
|
|
3
|
+import io.zipcoder.tc_spring_poll_application.domain.Poll;
|
|
|
4
|
+import io.zipcoder.tc_spring_poll_application.repositories.PollRepository;
|
|
|
5
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
6
|
+import org.springframework.http.HttpStatus;
|
|
|
7
|
+import org.springframework.http.ResponseEntity;
|
|
|
8
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
9
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
10
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
11
|
+
|
|
|
12
|
+@RestController
|
|
|
13
|
+public class PollController {
|
|
|
14
|
+
|
|
|
15
|
+ private PollRepository pollRepository;
|
|
|
16
|
+
|
|
|
17
|
+ @Autowired
|
|
|
18
|
+ public PollController(PollRepository pollRepository) {
|
|
|
19
|
+ this.pollRepository = pollRepository;
|
|
|
20
|
+ }
|
|
|
21
|
+
|
|
|
22
|
+ @RequestMapping(value="/polls", method= RequestMethod.GET)
|
|
|
23
|
+ public ResponseEntity<Iterable<Poll>> getAllPolls() {
|
|
|
24
|
+ Iterable<Poll> allPolls = pollRepository.findAll();
|
|
|
25
|
+ return new ResponseEntity<>(allPolls, HttpStatus.OK);
|
|
|
26
|
+ }
|
|
|
27
|
+
|
|
|
28
|
+
|
|
|
29
|
+}
|
|
|
30
|
+
|
|
|
31
|
+
|
|
|
32
|
+
|