Browse Source

Corrected Packages

Nick Satinover 6 years ago
parent
commit
b3c8ffd4f9

src/test/java/io/zipcoder/tc_spring_poll_application/controller/PollController.java → src/main/java/io/zipcoder/tc_spring_poll_application/controllers/PollController.java View File

@@ -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
 }

src/test/java/io/zipcoder/tc_spring_poll_application/domain/Option.java → src/main/java/io/zipcoder/tc_spring_poll_application/domain/Option.java View File


src/test/java/io/zipcoder/tc_spring_poll_application/domain/Poll.java → src/main/java/io/zipcoder/tc_spring_poll_application/domain/Poll.java View File


src/test/java/io/zipcoder/tc_spring_poll_application/domain/Vote.java → src/main/java/io/zipcoder/tc_spring_poll_application/domain/Vote.java View File


src/test/java/io/zipcoder/tc_spring_poll_application/repositories/OptionRepository.java → src/main/java/io/zipcoder/tc_spring_poll_application/repositories/OptionRepository.java View File


src/test/java/io/zipcoder/tc_spring_poll_application/repositories/PollRepository.java → src/main/java/io/zipcoder/tc_spring_poll_application/repositories/PollRepository.java View File


src/test/java/io/zipcoder/tc_spring_poll_application/repositories/VoteRepository.java → src/main/java/io/zipcoder/tc_spring_poll_application/repositories/VoteRepository.java View File