aboutsummaryrefslogtreecommitdiff
path: root/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2025-03-06 21:41:39 -0500
committersowgro <tpoke.ferrari@gmail.com>2025-03-06 21:41:39 -0500
commitbb9ce55cb5b55a6aaed2399e39a01d68f2491ce3 (patch)
tree7df43079fa8d3e5c7b34c5ab13389018c1216078 /ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java
parenteb4edcc7e7e4f9a6a59bed6d3952486f179fc445 (diff)
downloadJellySolutions-bb9ce55cb5b55a6aaed2399e39a01d68f2491ce3.tar.gz
JellySolutions-bb9ce55cb5b55a6aaed2399e39a01d68f2491ce3.tar.bz2
JellySolutions-bb9ce55cb5b55a6aaed2399e39a01d68f2491ce3.zip
Push current changes (working on documentation and tests)
Diffstat (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java')
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java15
1 files changed, 6 insertions, 9 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 6b0bb71..dfcb8a3 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,8 +40,11 @@ public class CupboardController {
/**
* 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
+ * @param params The need to create
+ * @return OK response and the need if it was successful,
+ * CONFLICT if another need with the same name exists
+ * UNPROCESSABLE_ENTITY if the need contains bad data
+ * INTERNAL_SERVER_ERROR otherwise
*/
@PostMapping("")
public ResponseEntity<Need> createNeed(@RequestBody Map<String, String> params) {
@@ -50,10 +53,8 @@ public class CupboardController {
Need.GoalType goalType = GoalType.valueOf(params.get("maxGoal"));
try {
-
Need need = cupboardService.createNeed(name, maxGoal, goalType);
return new ResponseEntity<>(need, HttpStatus.OK);
-
} catch (DuplicateKeyException ex) {
return new ResponseEntity<>(HttpStatus.CONFLICT);
} catch (IllegalArgumentException ex) {
@@ -113,10 +114,8 @@ public class CupboardController {
*
* @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<br>
+ * @return ResponseEntity with {@link Need need} object and HTTP status of OK if found<br>
* ResponseEntity with HTTP status of NOT_FOUND if not found<br>
- * ResponseEntity with HTTP status of INTERNAL_SERVER_ERROR otherwise
*/
@GetMapping("/{id}")
public ResponseEntity<Need> getNeed(@PathVariable int id) {
@@ -129,7 +128,6 @@ public class CupboardController {
} else {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
-
} catch (IOException e) {
LOG.log(Level.SEVERE, e.getLocalizedMessage());
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
@@ -143,7 +141,6 @@ public class CupboardController {
* @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<Need> updateNeed(@RequestBody Need need) {
try {