From 734128698a92a60c73d00d6aef4e78270c58283a Mon Sep 17 00:00:00 2001 From: sowgro Date: Sun, 16 Feb 2025 14:18:30 -0500 Subject: Complete createNeed() --- .../ufund/api/ufundapi/controller/CupboardController.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/controller') 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 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 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("") -- cgit v1.2.3