Sfoglia il codice sorgente

requestbody;actuallyfinished

Seth 5 anni fa
parent
commit
27a044e981

+ 2
- 2
src/main/java/com/zipcodewilmington/bakery/Controllers/BakerController.java Vedi File

@@ -25,12 +25,12 @@ public class BakerController {
25 25
     }
26 26
 
27 27
     @PostMapping("/bakers")
28
-    public ResponseEntity<Baker> create(Baker baker) {
28
+    public ResponseEntity<Baker> create(@RequestBody Baker baker) {
29 29
         return new ResponseEntity<>(this.bakerRepository.save(baker), HttpStatus.CREATED);
30 30
     }
31 31
 
32 32
     @PutMapping("/bakers/{id}")
33
-    public ResponseEntity<Baker> update(@PathVariable Long id, Baker baker) {
33
+    public ResponseEntity<Baker> update(@PathVariable Long id, @RequestBody Baker baker) {
34 34
         Baker foundBaker = bakerRepository.findOne(id);
35 35
 
36 36
         foundBaker.setName(baker.getName());

+ 2
- 2
src/main/java/com/zipcodewilmington/bakery/Controllers/MuffinController.java Vedi File

@@ -25,12 +25,12 @@ public class MuffinController {
25 25
     }
26 26
 
27 27
     @PostMapping("/muffins")
28
-    public ResponseEntity<Muffin> create(Muffin muffin) {
28
+    public ResponseEntity<Muffin> create(@RequestBody Muffin muffin) {
29 29
         return new ResponseEntity<>(this.muffinRepository.save(muffin), HttpStatus.CREATED);
30 30
     }
31 31
 
32 32
     @PutMapping("/muffins/{id}")
33
-    public ResponseEntity<Muffin> update(@PathVariable Long id, Muffin muffin) {
33
+    public ResponseEntity<Muffin> update(@PathVariable Long id, @RequestBody Muffin muffin) {
34 34
         Muffin foundMuffin = muffinRepository.findOne(id);
35 35
         foundMuffin.setFlavor(muffin.getFlavor());
36 36
 

+ 8
- 0
src/main/java/com/zipcodewilmington/bakery/Models/Baker.java Vedi File

@@ -1,5 +1,6 @@
1 1
 package com.zipcodewilmington.bakery.Models;
2 2
 
3
+import javax.persistence.Column;
3 4
 import javax.persistence.Entity;
4 5
 import javax.persistence.GeneratedValue;
5 6
 import javax.persistence.Id;
@@ -10,10 +11,13 @@ public class Baker {
10 11
     @GeneratedValue
11 12
     private Long id;
12 13
 
14
+    @Column
13 15
     private String name;
14 16
 
17
+    @Column
15 18
     private String employeeId;
16 19
 
20
+    @Column
17 21
     private String specialty;
18 22
 
19 23
     public Baker(String name, String employeeId, String specialty) {
@@ -22,6 +26,10 @@ public class Baker {
22 26
         this.specialty = specialty;
23 27
     }
24 28
 
29
+    public Baker() {
30
+
31
+    }
32
+
25 33
     public Long getId() {
26 34
         return id;
27 35
     }

+ 6
- 0
src/main/java/com/zipcodewilmington/bakery/Models/Muffin.java Vedi File

@@ -1,6 +1,7 @@
1 1
 package com.zipcodewilmington.bakery.Models;
2 2
 
3 3
 
4
+import javax.persistence.Column;
4 5
 import javax.persistence.Entity;
5 6
 import javax.persistence.GeneratedValue;
6 7
 import javax.persistence.Id;
@@ -12,12 +13,17 @@ public class Muffin {
12 13
     @GeneratedValue
13 14
     private Long id;
14 15
 
16
+    @Column
15 17
     private String flavor;
16 18
 
17 19
     public Muffin(String flavor) {
18 20
         this.flavor = flavor;
19 21
     }
20 22
 
23
+    public Muffin(){
24
+
25
+    }
26
+
21 27
     public Long getId() {
22 28
         return id;
23 29
     }

+ 1
- 1
src/main/java/com/zipcodewilmington/bakery/Repositories/BakerRepository.java Vedi File

@@ -4,6 +4,6 @@ import com.zipcodewilmington.bakery.Models.Baker;
4 4
 import org.springframework.data.repository.CrudRepository;
5 5
 import org.springframework.stereotype.Repository;
6 6
 
7
-@Repository
7
+
8 8
 public interface BakerRepository extends CrudRepository<Baker, Long>{
9 9
 }

+ 0
- 1
src/main/java/com/zipcodewilmington/bakery/Repositories/MuffinRepository.java Vedi File

@@ -4,6 +4,5 @@ import com.zipcodewilmington.bakery.Models.Muffin;
4 4
 import org.springframework.data.repository.CrudRepository;
5 5
 import org.springframework.stereotype.Repository;
6 6
 
7
-@Repository
8 7
 public interface MuffinRepository extends CrudRepository<Muffin, Long> {
9 8
 }