From 9a3a03dab857fc677be9a0d0801cb916c3b7893c Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Sun, 16 Feb 2025 12:56:52 -0500 Subject: Updated U-Fund type in ReadMe --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 97b96b0..372f031 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# U-Fund: _____ _replace with your particular fundraising type_ _____ +# U-Fund: Coral Reefs # Modify this document to expand any and all sections that are applicable for a better understanding from your users/testers/collaborators (remove this comment and other instructions areas for your FINAL release) An online U-Fund system built in Java **21** and ___ _replace with other platform requirements_ ___ -- cgit v1.2.3 From d24c29af1dbed62842225b9205b3ee5cb6bc4221 Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Sun, 16 Feb 2025 12:57:52 -0500 Subject: Moved u-fund uml from root directory to docs/target --- docs/u-fund.drawio.png | Bin 0 -> 90269 bytes u-fund.drawio.png | Bin 90269 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 docs/u-fund.drawio.png delete mode 100644 u-fund.drawio.png diff --git a/docs/u-fund.drawio.png b/docs/u-fund.drawio.png new file mode 100644 index 0000000..e607a2b Binary files /dev/null and b/docs/u-fund.drawio.png differ diff --git a/u-fund.drawio.png b/u-fund.drawio.png deleted file mode 100644 index e607a2b..0000000 Binary files a/u-fund.drawio.png and /dev/null differ -- cgit v1.2.3 From 3707c91f4c260cede04ddff7e7270057cb628798 Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Sun, 16 Feb 2025 12:58:10 -0500 Subject: Replaced domain model placeholder with actual model --- docs/domain-model-placeholder.png | Bin 28823 -> 0 bytes docs/domain-model.png | Bin 0 -> 56620 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 docs/domain-model-placeholder.png create mode 100644 docs/domain-model.png diff --git a/docs/domain-model-placeholder.png b/docs/domain-model-placeholder.png deleted file mode 100644 index ba1ef65..0000000 Binary files a/docs/domain-model-placeholder.png and /dev/null differ diff --git a/docs/domain-model.png b/docs/domain-model.png new file mode 100644 index 0000000..75b4377 Binary files /dev/null and b/docs/domain-model.png differ -- cgit v1.2.3 From 384ba7ea4205196085a060b18db43f29aac3079b Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Sun, 16 Feb 2025 13:15:27 -0500 Subject: Implemented getNeed method --- .../ufundapi/controller/CupboardController.java | 37 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 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 c99a95b..27185b0 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 @@ -1,19 +1,27 @@ package com.ufund.api.ufundapi.controller; +import java.util.logging.Level; +import java.util.logging.Logger; + import com.ufund.api.ufundapi.model.Cupboard; import com.ufund.api.ufundapi.model.Need; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.io.IOException; import java.util.ArrayList; @RestController @RequestMapping("cupboard") public class CupboardController { + private static final Logger LOG = Logger.getLogger(CupboardController.class.getName()); private ArrayList needs; private Cupboard cupboard; @PostMapping("") - public void createNeed(@RequestBody Need need) {; + public void createNeed(@RequestBody Need need) { cupboard.createNeed(need); } @@ -27,9 +35,32 @@ public class CupboardController { return cupboard.findNeeds(name); } + /** + * Responds to the GET request for a {@linkplain Need need} for the given id + * + * @param id The id used to locate the {@link Need need} + * + * @return ResponseEntity with {@link Need need} object and HTTP status of OK if found
+ * ResponseEntity with HTTP status of NOT_FOUND if not found
+ * ResponseEntity with HTTP status of INTERNAL_SERVER_ERROR otherwise + */ @GetMapping("/{id}") - public Need getNeed(@PathVariable int id) { - return cupboard.getNeed(id); + public ResponseEntity getNeed(@PathVariable int id) { + LOG.log(Level.INFO, "GET /need/{0}", id); + + try { + Need need = cupboard.getNeed(id); + if (need != null) { + return new ResponseEntity<>(need, HttpStatus.OK); + } else { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + + } catch (IOException e) { + LOG.log(Level.SEVERE, e.getLocalizedMessage()); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } @PutMapping("") -- cgit v1.2.3