|
@@ -2,24 +2,39 @@ 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.stereotype.Controller;
|
|
9
|
+import org.springframework.stereotype.Repository;
|
|
10
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
11
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
12
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
13
|
+import org.springframework.web.bind.annotation.RestController;
|
7
|
14
|
|
|
15
|
+import javax.persistence.Entity;
|
|
16
|
+
|
|
17
|
+@RestController
|
|
18
|
+//@RequestMapping("/bake")
|
8
|
19
|
public class BakerController {
|
|
20
|
+ @Autowired
|
9
|
21
|
private BakerRepository bakerRepository;
|
10
|
22
|
|
|
23
|
+ @RequestMapping("/")
|
11
|
24
|
public ResponseEntity<Iterable<Baker>> index() {
|
12
|
25
|
return new ResponseEntity<>(this.bakerRepository.findAll(), HttpStatus.OK);
|
13
|
26
|
}
|
14
|
|
-
|
|
27
|
+ //@PostMapping("/request")
|
|
28
|
+ @RequestMapping
|
15
|
29
|
public ResponseEntity<Baker> show(Long id) {
|
16
|
30
|
return new ResponseEntity<>(this.bakerRepository.findById(id).get(), HttpStatus.OK);
|
17
|
31
|
}
|
18
|
|
-
|
|
32
|
+ @RequestMapping
|
19
|
33
|
public ResponseEntity<Baker> create(Baker baker) {
|
20
|
34
|
return new ResponseEntity<>(this.bakerRepository.save(baker), HttpStatus.CREATED);
|
21
|
35
|
}
|
22
|
36
|
|
|
37
|
+ @RequestMapping//(method = RequestMethod.GET)
|
23
|
38
|
public ResponseEntity<Baker> update(Long id, Baker baker) {
|
24
|
39
|
Baker foundBaker = bakerRepository.findById(id).get();
|
25
|
40
|
|