diff options
| author | sowgro <tpoke.ferrari@gmail.com> | 2025-02-16 14:18:30 -0500 |
|---|---|---|
| committer | sowgro <tpoke.ferrari@gmail.com> | 2025-02-16 14:18:30 -0500 |
| commit | 734128698a92a60c73d00d6aef4e78270c58283a (patch) | |
| tree | 8f55aa940552481bb394c083c8552b1f8b634963 /ufund-api/src/main/java/com | |
| parent | 5e073d64d3d364c090f21c5e34ae273955009a1a (diff) | |
| download | JellySolutions-734128698a92a60c73d00d6aef4e78270c58283a.tar.gz JellySolutions-734128698a92a60c73d00d6aef4e78270c58283a.tar.bz2 JellySolutions-734128698a92a60c73d00d6aef4e78270c58283a.zip | |
Complete createNeed()
Diffstat (limited to '')
| -rw-r--r-- | ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java index 106b2e0..d6b71fd 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java @@ -20,9 +20,20 @@ public class CupboardController { private ArrayList<Need> needs; private Cupboard cupboard; + /** + * Creates a Need with the provided object + * + * @param need The need to create + * @return OK response and the need if it was successful, INTERNAL_SERVER_ERROR otherwise + */ @PostMapping("") - public void createNeed(@RequestBody Need need) { - cupboard.createNeed(need); + public ResponseEntity<Need> createNeed(@RequestBody Need need) { + try { + cupboard.createNeed(need); + return new ResponseEntity<>(need, HttpStatus.OK); + } catch (IOException ex) { + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } } @GetMapping("") |
