From 6c32da25ccbcd0568f7b34cd81565609625435ef Mon Sep 17 00:00:00 2001 From: beanplebs Date: Sun, 16 Feb 2025 14:14:20 -0500 Subject: updateNeed Controller and Cupboard functionality --- .../com/ufund/api/ufundapi/controller/CupboardController.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java') 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..0de3403 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 @@ -41,8 +41,14 @@ public class CupboardController { } @PutMapping("") - public void updateNeed(@RequestBody Need need) { - cupboard.updateNeed(need); + public ResponseEntity updateNeed(@RequestBody Need need) { + try { + need = cupboard.updateNeed(need); + return new ResponseEntity<>(need, HttpStatus.OK); + } catch (IOException e) { + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } @DeleteMapping("/{id}") -- cgit v1.2.3 From 2f4119f80731b62fce2eeff5f1c1dc77ae53c180 Mon Sep 17 00:00:00 2001 From: benal01 Date: Sun, 16 Feb 2025 14:41:34 -0500 Subject: javadoc --- .../com/ufund/api/ufundapi/controller/CupboardController.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java') 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 0de3403..8d394c1 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 @@ -40,6 +40,14 @@ public class CupboardController { return cupboard.getNeed(id); } + + /** + * Updates a Need with the provided one + * + * @param need The need to update + * @return OK response and the need if it was successful, or INTERNAL_SERVER_ERROR if there was an issue + */ + @PutMapping("") public ResponseEntity updateNeed(@RequestBody Need need) { try { @@ -48,7 +56,6 @@ public class CupboardController { } catch (IOException e) { return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } - } @DeleteMapping("/{id}") -- cgit v1.2.3