Kaynağa Gözat

Merge branch 'master' of https://github.com/Zipcoder/CR-MacroLabs-Spring-QuickPollApplication

Brian He 8 yıl önce
ebeveyn
işleme
331d14ce27
1 değiştirilmiş dosya ile 24 ekleme ve 8 silme
  1. 24
    8
      README.md

+ 24
- 8
README.md Dosyayı Görüntüle

@@ -108,8 +108,10 @@
108 108
 * Create a `PollController` class in the `controller` sub package.
109 109
 	* `PollController` signature should be `annotated` with `@RestController`
110 110
 
111
-* `PollController` has a `pollRepository` instance variable of type `PollRepository`
112
-	* `pollRepository` should be `annotated` with `@Inject`
111
+* `PollController` has a `pollRepository` instance variable of type `PollRepository`  
112
+
113
+* Create a constructor that accepts a `PollRepository` argument and assigns its value to the `pollRepository` member variable.  
114
+	* Mark the constructor with the `@Autowired` annotation.
113 115
 
114 116
 
115 117
 ### Part 3.1.1 - Create `GET` request method
@@ -248,16 +250,20 @@ public ResponseEntity<?> deletePoll(@PathVariable Long pollId) {
248 250
     "question": "What's the best netflix original?",
249 251
     "options": [
250 252
         {
251
-            "id": 1
253
+            "id": 1,
254
+            "value": "Stranger Things"
252 255
         },
253 256
         {
254
-            "id": 2
257
+            "id": 2,
258
+            "value": "The Get Down"
255 259
         },
256 260
         {
257
-            "id": 3
261
+            "id": 3,
262
+            "value": "Black Mirror"
258 263
         },
259 264
         {
260
-            "id": 4
265
+            "id": 4,
266
+            "value": "Orange is the New Black"
261 267
         }
262 268
     ]
263 269
 }
@@ -273,8 +279,13 @@ public ResponseEntity<?> deletePoll(@PathVariable Long pollId) {
273 279
 ```java
274 280
 @RestController
275 281
 public class VoteController {
276
-    @Inject
282
+
277 283
     private VoteRepository voteRepository;
284
+    
285
+    @Autowired
286
+    public VoteController(VoteRepository voteRepository) {
287
+    	this.voteRepository = voteRepository;
288
+    }
278 289
 
279 290
     @RequestMapping(value = "/polls/{pollId}/votes", method = RequestMethod.POST)
280 291
     public ResponseEntity<?> createVote(@PathVariable Long pollId, @RequestBody Vote
@@ -414,8 +425,13 @@ public class VoteResult {
414 425
 ```java
415 426
 @RestController
416 427
 public class ComputeResultController {
417
-    @Inject
428
+    
418 429
     private VoteRepository voteRepository;
430
+    
431
+    @Autowired
432
+    public ComputeResultController(VoteRepository voteRepository) {
433
+    	this.voteRepository = voteRepository;
434
+    }
419 435
 
420 436
     @RequestMapping(value = "/computeresult", method = RequestMethod.GET)
421 437
     public ResponseEntity<?> computeResult(@RequestParam Long pollId) {