|
@@ -5,10 +5,7 @@ import com.zipcodewilmington.bakery.Repositories.MuffinRepository;
|
5
|
5
|
import org.springframework.beans.factory.annotation.Autowired;
|
6
|
6
|
import org.springframework.http.HttpStatus;
|
7
|
7
|
import org.springframework.http.ResponseEntity;
|
8
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
9
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
10
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
11
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
8
|
+import org.springframework.web.bind.annotation.*;
|
12
|
9
|
|
13
|
10
|
@RestController
|
14
|
11
|
@RequestMapping
|
|
@@ -26,12 +23,12 @@ public class MuffinController {
|
26
|
23
|
public ResponseEntity<Muffin> show(Long id) {
|
27
|
24
|
return new ResponseEntity<>(this.muffinRepository.findOne(id), HttpStatus.OK);
|
28
|
25
|
}
|
29
|
|
- @GetMapping(value = "/muffin")
|
|
26
|
+ @PostMapping(value = "/muffin")
|
30
|
27
|
public ResponseEntity<Muffin> create(Muffin muffin) {
|
31
|
28
|
return new ResponseEntity<>(this.muffinRepository.save(muffin), HttpStatus.CREATED);
|
32
|
29
|
}
|
33
|
30
|
|
34
|
|
- @GetMapping(value ="/muffin/{id}")
|
|
31
|
+ @PutMapping(value ="/muffin/{id}")
|
35
|
32
|
public ResponseEntity<Muffin> update(Long id, Muffin muffin) {
|
36
|
33
|
Muffin foundMuffin = muffinRepository.findOne(id);
|
37
|
34
|
foundMuffin.setFlavor(muffin.getFlavor());
|
|
@@ -39,7 +36,7 @@ public class MuffinController {
|
39
|
36
|
return new ResponseEntity<>(this.muffinRepository.save(foundMuffin), HttpStatus.OK);
|
40
|
37
|
}
|
41
|
38
|
|
42
|
|
- @GetMapping(value = "/muffin/{id}")
|
|
39
|
+ @DeleteMapping(value = "/muffin/{id}")
|
43
|
40
|
public ResponseEntity<Boolean> destroy(Long id) {
|
44
|
41
|
this.muffinRepository.delete(id);
|
45
|
42
|
return new ResponseEntity<>(true, HttpStatus.OK);
|