mpierse il y a 6 ans
Parent
révision
1d7499e7ee

+ 8
- 0
src/main/java/com/zipcodewilmington/bakery/Controllers/BakerController.java Voir le fichier

@@ -2,8 +2,10 @@ package com.zipcodewilmington.bakery.Controllers;
2 2
 
3 3
 import com.zipcodewilmington.bakery.Models.Baker;
4 4
 import com.zipcodewilmington.bakery.Repositories.BakerRepository;
5
+import org.springframework.beans.factory.annotation.Autowired;
5 6
 import org.springframework.http.HttpStatus;
6 7
 import org.springframework.http.ResponseEntity;
8
+import org.springframework.web.bind.annotation.GetMapping;
7 9
 import org.springframework.web.bind.annotation.RequestMapping;
8 10
 import org.springframework.web.bind.annotation.RestController;
9 11
 
@@ -11,20 +13,25 @@ import org.springframework.web.bind.annotation.RestController;
11 13
 @RequestMapping
12 14
 public class BakerController {
13 15
 
16
+    @Autowired
14 17
     private BakerRepository bakerRepository;
15 18
 
19
+    @GetMapping(value = "/baker")
16 20
     public ResponseEntity<Iterable<Baker>> index() {
17 21
         return new ResponseEntity<>(this.bakerRepository.findAll(), HttpStatus.OK);
18 22
     }
19 23
 
24
+    @GetMapping(value = "/baker/{id}")
20 25
     public ResponseEntity<Baker> show(Long id) {
21 26
         return new ResponseEntity<>(this.bakerRepository.findOne(id), HttpStatus.OK);
22 27
     }
23 28
 
29
+    @GetMapping(value = "/baker")
24 30
     public ResponseEntity<Baker> create(Baker baker) {
25 31
         return new ResponseEntity<>(this.bakerRepository.save(baker), HttpStatus.CREATED);
26 32
     }
27 33
 
34
+    @GetMapping(value = "/baker/{id}")
28 35
     public ResponseEntity<Baker> update(Long id, Baker baker) {
29 36
         Baker foundBaker = bakerRepository.findOne(id);
30 37
 
@@ -34,6 +41,7 @@ public class BakerController {
34 41
         return new ResponseEntity<>(this.bakerRepository.save(foundBaker), HttpStatus.OK);
35 42
     }
36 43
 
44
+    @GetMapping(value = "/baker/{id}")
37 45
     public ResponseEntity<Boolean> destroy(Long id) {
38 46
         this.bakerRepository.delete(id);
39 47
         return new ResponseEntity<>(true, HttpStatus.OK);

+ 5
- 3
src/main/java/com/zipcodewilmington/bakery/Controllers/MuffinController.java Voir le fichier

@@ -17,20 +17,21 @@ public class MuffinController {
17 17
     @Autowired
18 18
     private MuffinRepository muffinRepository;
19 19
 
20
-    @GetMapping(value="/polls/votes")
20
+    @GetMapping(value="/muffin")
21 21
     public ResponseEntity<Iterable<Muffin>> index() {
22 22
         return new ResponseEntity<>(this.muffinRepository.findAll(), HttpStatus.OK);
23 23
     }
24 24
 
25
-
25
+    @GetMapping(value="/muffin/{id}")
26 26
     public ResponseEntity<Muffin> show(Long id) {
27 27
         return new ResponseEntity<>(this.muffinRepository.findOne(id), HttpStatus.OK);
28 28
     }
29
-
29
+    @GetMapping(value = "/muffin")
30 30
     public ResponseEntity<Muffin> create(Muffin muffin) {
31 31
         return new ResponseEntity<>(this.muffinRepository.save(muffin), HttpStatus.CREATED);
32 32
     }
33 33
 
34
+    @GetMapping(value ="/muffin/{id}")
34 35
     public ResponseEntity<Muffin> update(Long id, Muffin muffin) {
35 36
         Muffin foundMuffin = muffinRepository.findOne(id);
36 37
         foundMuffin.setFlavor(muffin.getFlavor());
@@ -38,6 +39,7 @@ public class MuffinController {
38 39
         return new ResponseEntity<>(this.muffinRepository.save(foundMuffin), HttpStatus.OK);
39 40
     }
40 41
 
42
+    @GetMapping(value = "/muffin/{id}")
41 43
     public ResponseEntity<Boolean> destroy(Long id) {
42 44
         this.muffinRepository.delete(id);
43 45
         return new ResponseEntity<>(true, HttpStatus.OK);

+ 8
- 3
src/main/java/com/zipcodewilmington/bakery/Models/Baker.java Voir le fichier

@@ -1,5 +1,7 @@
1 1
 package com.zipcodewilmington.bakery.Models;
2 2
 
3
+import org.springframework.web.bind.annotation.PathVariable;
4
+
3 5
 import javax.persistence.Column;
4 6
 import javax.persistence.Entity;
5 7
 import javax.persistence.GeneratedValue;
@@ -9,13 +11,16 @@ import javax.persistence.Id;
9 11
 public class Baker {
10 12
     @Id
11 13
     @GeneratedValue
14
+    @Column(name = "id")
12 15
     private Long id;
13 16
 
14
-    @Column
17
+    @Column(name = "bakerName")
15 18
     private String name;
16
-    @Column
19
+
20
+    @Column(name = "employeeId")
17 21
     private String employeeId;
18
-    @Column
22
+
23
+    @Column(name = "specialty")
19 24
     private String specialty;
20 25
 
21 26
     public Baker(String name, String employeeId, String specialty) {

+ 5
- 1
src/main/java/com/zipcodewilmington/bakery/Models/Muffin.java Voir le fichier

@@ -2,14 +2,18 @@ package com.zipcodewilmington.bakery.Models;
2 2
 
3 3
 import javax.persistence.Column;
4 4
 import javax.persistence.Entity;
5
+import javax.persistence.GeneratedValue;
5 6
 import javax.persistence.Id;
6 7
 
7 8
 @Entity
8 9
 public class Muffin {
9 10
 
10 11
     @Id
12
+    @GeneratedValue
13
+    @Column(name = "id")
11 14
     private Long id;
12
-    @Column
15
+
16
+    @Column(name = "flavor")
13 17
     private String flavor;
14 18
 
15 19
     public Muffin(String flavor) {