aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--docs/index.md7
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java45
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/model/Cupboard.java4
4 files changed, 47 insertions, 11 deletions
diff --git a/README.md b/README.md
index 372f031..ffedf19 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# U-Fund: Coral Reefs
+# 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_ ___
diff --git a/docs/index.md b/docs/index.md
index 9f7d821..b36ce01 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -4,8 +4,11 @@ Welcome to the PROJECT Project!
## Team
-* MEMBER1
-* MEMBER2
+- Ben Almstead
+- Tyler Ferrari
+- Hayden Hartman
+- Akash Keshav
+- Angelina Zhen
## [Design Documentation](DesignDoc)
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 255eba0..8af3fee 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
@@ -18,9 +18,20 @@ public class CupboardController {
private static final Logger LOG = Logger.getLogger(CupboardController.class.getName());
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);
+ }
}
/**
@@ -54,14 +65,36 @@ 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 void updateNeed(@RequestBody Need need) {
- cupboard.updateNeed(need);
+ public ResponseEntity<Need> 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}")
- public void deleteNeed(@PathVariable int id) {
- cupboard.removeNeed(id);
+ public ResponseEntity<Need> deleteNeed(@PathVariable int id) {
+ try {
+ if (cupboard.getNeed(id) != null) {
+ cupboard.removeNeed(id);
+ return new ResponseEntity<>(HttpStatus.OK);
+ } else {
+ return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+ }
+ } catch (IOException e) {
+ return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
+ }
}
}
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Cupboard.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Cupboard.java
index a626561..0ce015c 100644
--- a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Cupboard.java
+++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Cupboard.java
@@ -23,8 +23,8 @@ public class Cupboard {
return dao.findNeeds(name);
}
- public void updateNeed(Need need) throws IOException {
- dao.updateNeed(need);
+ public Need updateNeed(Need need) throws IOException {
+ return dao.updateNeed(need);
}
public void removeNeed(int id) throws IOException {