소스 검색

Part 3.1.8 - Test Poll Creating Capabilities

Nick Satinover 6 년 전
부모
커밋
09450b2bfd
1개의 변경된 파일18개의 추가작업 그리고 0개의 파일을 삭제
  1. 18
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/controllers/PollController.java

+ 18
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/controllers/PollController.java 파일 보기

@@ -43,5 +43,23 @@ public class PollController {
43 43
         return new ResponseEntity<>(httpHeaders, HttpStatus.CREATED);
44 44
     }
45 45
 
46
+    @RequestMapping(value = "/polls/{pollId}", method = RequestMethod.GET)
47
+    public ResponseEntity<?> getPoll(@PathVariable Long pollId){
48
+        Poll p = pollRepository.findOne(pollId);
49
+        return new ResponseEntity<>(p, HttpStatus.OK);
50
+    }
51
+
52
+    @RequestMapping(value = "/polls/{pollId}", method = RequestMethod.PUT)
53
+    public ResponseEntity<?> updatePoll(@RequestBody Poll poll, @PathVariable Long pollId){
54
+        Poll p = pollRepository.save(poll);
55
+        return new ResponseEntity<>(HttpStatus.OK);
56
+    }
57
+
58
+    @RequestMapping(value = "/polls{pollId}", method = RequestMethod.DELETE)
59
+    public ResponseEntity<?> deletePoll(@PathVariable Long pollId){
60
+        pollRepository.delete(pollId);
61
+        return new ResponseEntity<>(HttpStatus.OK);
62
+    }
63
+
46 64
 
47 65
 }