diff options
author | sowgro <tpoke.ferrari@gmail.com> | 2025-02-23 14:29:52 -0500 |
---|---|---|
committer | sowgro <tpoke.ferrari@gmail.com> | 2025-02-23 14:29:52 -0500 |
commit | 2027ef68ee156212d452e8d3d2e765518a2ed968 (patch) | |
tree | 55dc3b45805fa15003f42477f95f1f4a6ab807eb | |
parent | 1d46022ec65597c46f27788eae520f36f0bb0324 (diff) | |
parent | a7727b470b97dc6ae721f2e32f86c230bf24263d (diff) | |
download | JellySolutions-2027ef68ee156212d452e8d3d2e765518a2ed968.tar.gz JellySolutions-2027ef68ee156212d452e8d3d2e765518a2ed968.tar.bz2 JellySolutions-2027ef68ee156212d452e8d3d2e765518a2ed968.zip |
Merge remote-tracking branch 'origin/main'
# Conflicts:
# ufund-api/data/cupboard.json
-rw-r--r-- | ufund-api/data/cupboard.json | 2 | ||||
-rw-r--r-- | ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java | 23 |
2 files changed, 19 insertions, 6 deletions
diff --git a/ufund-api/data/cupboard.json b/ufund-api/data/cupboard.json index f8e7fc4..a30bf2e 100644 --- a/ufund-api/data/cupboard.json +++ b/ufund-api/data/cupboard.json @@ -1 +1 @@ -[{"name":"Test","id":2,"maxGoal":100.0,"type":"PHYSICAL","filterAttributes":null,"Current":0.0}]
\ No newline at end of file +[{"name":"Money for coral","id":1,"maxGoal":100.0,"type":"MONETARY","filterAttributes":null,"Current":0.0}]
\ No newline at end of file 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 5099bbe..4b2a04d 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,16 +1,23 @@ package com.ufund.api.ufundapi.controller; +import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; -import com.ufund.api.ufundapi.model.Need; - -import com.ufund.api.ufundapi.persistence.CupboardDAO; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; -import java.io.IOException; +import com.ufund.api.ufundapi.model.Need; +import com.ufund.api.ufundapi.persistence.CupboardDAO; @RestController @RequestMapping("cupboard") @@ -36,6 +43,12 @@ public class CupboardController { @PostMapping("") public ResponseEntity<Need> createNeed(@RequestBody Need need) { try { + if (need.getMaxGoal() <= 0) { + return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + } + if (need.getMaxGoal() < need.getCurrent()) { + return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + } cupboardDAO.createNeed(need); return new ResponseEntity<>(need, HttpStatus.OK); } catch (IOException ex) { |