소스 검색

requestbody;actuallyfinished

Seth 5 년 전
부모
커밋
27a044e981

+ 2
- 2
src/main/java/com/zipcodewilmington/bakery/Controllers/BakerController.java 파일 보기

25
     }
25
     }
26
 
26
 
27
     @PostMapping("/bakers")
27
     @PostMapping("/bakers")
28
-    public ResponseEntity<Baker> create(Baker baker) {
28
+    public ResponseEntity<Baker> create(@RequestBody Baker baker) {
29
         return new ResponseEntity<>(this.bakerRepository.save(baker), HttpStatus.CREATED);
29
         return new ResponseEntity<>(this.bakerRepository.save(baker), HttpStatus.CREATED);
30
     }
30
     }
31
 
31
 
32
     @PutMapping("/bakers/{id}")
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
         Baker foundBaker = bakerRepository.findOne(id);
34
         Baker foundBaker = bakerRepository.findOne(id);
35
 
35
 
36
         foundBaker.setName(baker.getName());
36
         foundBaker.setName(baker.getName());

+ 2
- 2
src/main/java/com/zipcodewilmington/bakery/Controllers/MuffinController.java 파일 보기

25
     }
25
     }
26
 
26
 
27
     @PostMapping("/muffins")
27
     @PostMapping("/muffins")
28
-    public ResponseEntity<Muffin> create(Muffin muffin) {
28
+    public ResponseEntity<Muffin> create(@RequestBody Muffin muffin) {
29
         return new ResponseEntity<>(this.muffinRepository.save(muffin), HttpStatus.CREATED);
29
         return new ResponseEntity<>(this.muffinRepository.save(muffin), HttpStatus.CREATED);
30
     }
30
     }
31
 
31
 
32
     @PutMapping("/muffins/{id}")
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
         Muffin foundMuffin = muffinRepository.findOne(id);
34
         Muffin foundMuffin = muffinRepository.findOne(id);
35
         foundMuffin.setFlavor(muffin.getFlavor());
35
         foundMuffin.setFlavor(muffin.getFlavor());
36
 
36
 

+ 8
- 0
src/main/java/com/zipcodewilmington/bakery/Models/Baker.java 파일 보기

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

+ 6
- 0
src/main/java/com/zipcodewilmington/bakery/Models/Muffin.java 파일 보기

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

+ 1
- 1
src/main/java/com/zipcodewilmington/bakery/Repositories/BakerRepository.java 파일 보기

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

+ 0
- 1
src/main/java/com/zipcodewilmington/bakery/Repositories/MuffinRepository.java 파일 보기

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