|
@@ -1,13 +1,11 @@
|
1
|
|
-package io.zipcoder.tc_spring_poll_application.controller;
|
|
1
|
+package io.zipcoder.tc_spring_poll_application.controllers;
|
2
|
2
|
|
3
|
3
|
import io.zipcoder.tc_spring_poll_application.domain.Poll;
|
4
|
4
|
import io.zipcoder.tc_spring_poll_application.repositories.PollRepository;
|
5
|
5
|
import org.springframework.beans.factory.annotation.Autowired;
|
6
|
6
|
import org.springframework.http.HttpStatus;
|
7
|
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;
|
|
8
|
+import org.springframework.web.bind.annotation.*;
|
11
|
9
|
|
12
|
10
|
@RestController
|
13
|
11
|
public class PollController {
|
|
@@ -25,5 +23,11 @@ public class PollController {
|
25
|
23
|
return new ResponseEntity<>(allPolls, HttpStatus.OK);
|
26
|
24
|
}
|
27
|
25
|
|
|
26
|
+ @RequestMapping(value = "/polls", method = RequestMethod.POST)
|
|
27
|
+ public ResponseEntity<?> createPoll(@RequestBody Poll poll){
|
|
28
|
+ poll = pollRepository.save(poll);
|
|
29
|
+ return new ResponseEntity<>(null, HttpStatus.CREATED);
|
|
30
|
+ }
|
|
31
|
+
|
28
|
32
|
|
29
|
33
|
}
|