diff options
| author | benal01 <bja4245@rit.edu> | 2025-03-31 10:10:41 -0400 | 
|---|---|---|
| committer | benal01 <bja4245@rit.edu> | 2025-03-31 10:10:41 -0400 | 
| commit | 227360990424abe323c44664b1d58d667b89a92f (patch) | |
| tree | e4df542219cb69bc433b9e1a5a0974ab9442a8c3 | |
| parent | cfe40fa1e416fbf4586ef36b63a145453a4d6224 (diff) | |
| download | JellySolutions-227360990424abe323c44664b1d58d667b89a92f.tar.gz JellySolutions-227360990424abe323c44664b1d58d667b89a92f.tar.bz2 JellySolutions-227360990424abe323c44664b1d58d667b89a92f.zip  | |
backend support for description
3 files changed, 17 insertions, 6 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 d426aee..ea86aa8 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 @@ -5,7 +5,6 @@ import java.util.Map;  import java.util.logging.Level;  import java.util.logging.Logger; -import com.ufund.api.ufundapi.service.AuthService;  import org.springframework.http.HttpStatus;  import org.springframework.http.ResponseEntity;  import org.springframework.web.bind.annotation.DeleteMapping; @@ -22,6 +21,7 @@ import org.springframework.web.bind.annotation.RestController;  import com.ufund.api.ufundapi.DuplicateKeyException;  import com.ufund.api.ufundapi.model.Need;  import com.ufund.api.ufundapi.model.Need.GoalType; +import com.ufund.api.ufundapi.service.AuthService;  import com.ufund.api.ufundapi.service.CupboardService;  @RestController @@ -58,11 +58,12 @@ public class CupboardController {          String location = (String) params.get("location");          double maxGoal = ((Number) params.get("maxGoal")).doubleValue();          boolean urgent = (Boolean) params.get("urgent"); +        String description = (String) params.get("description");          Need.GoalType goalType = GoalType.valueOf((String) params.get("type"));          try {              authService.keyHasAccessToCupboard(key); -            Need need = cupboardService.createNeed(name, location, maxGoal, goalType, urgent); +            Need need = cupboardService.createNeed(name, location, maxGoal, goalType, urgent, description);              return new ResponseEntity<>(need, HttpStatus.OK);          } catch (DuplicateKeyException ex) {              LOG.log(Level.WARNING, ex.getLocalizedMessage()); diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java index 55a9441..35e81b3 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java @@ -17,6 +17,7 @@ public class Need {      @JsonProperty("maxGoal") private double maxGoal;      @JsonProperty("urgent") private boolean urgent;      @JsonProperty("current") private double current; +    @JsonProperty("description") private String description;      /**       * Create a new need, used by the controller @@ -27,14 +28,16 @@ public class Need {       * @param maxGoal The maximum goal for this need       * @param type The type of need (monetary, physical)       * @param urgent The urgency of the need +     * @param description The description of the need       */ -    public Need(@JsonProperty("name") String name, @JsonProperty("location") String location, @JsonProperty("id") int id, @JsonProperty("maxGoal") double maxGoal, @JsonProperty("type") GoalType type, @JsonProperty("urgent") boolean urgent) { +    public Need(@JsonProperty("name") String name, @JsonProperty("location") String location, @JsonProperty("id") int id, @JsonProperty("maxGoal") double maxGoal, @JsonProperty("type") GoalType type, @JsonProperty("urgent") boolean urgent, @JsonProperty("Description") String description) {          this.id = id;          this.location = location;          this.name = name;          this.maxGoal = maxGoal;          this.type = type;          this.urgent = urgent; +        this.description = description;      }      /** @@ -45,13 +48,15 @@ public class Need {       * @param maxGoal The maximum goal for this need       * @param type    The type of need (monetary, physical)       * @param urgent The urgency of the need +     * @param description The description of the need       */ -    public Need(String name, String location, double maxGoal, GoalType type, boolean urgent) { +    public Need(String name, String location, double maxGoal, GoalType type, boolean urgent, String description) {          this.name = name;          this.location = location;          this.type = type;          this.maxGoal = maxGoal;          this.urgent = urgent; +        this.description = description;      }      /** @@ -68,6 +73,7 @@ public class Need {          this.maxGoal = other.maxGoal;          this.current = other.current;          this.urgent = other.urgent; +        this.description = other.description;      }      public String getName() { @@ -94,6 +100,7 @@ public class Need {          return current;      } +      public void setCurrent(double current) {          this.current = current;      } diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java index 4dcfcad..d216b01 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java @@ -25,13 +25,16 @@ public class CupboardService {       * Creates a new Need       *       * @param name The name of the need to create +     * @param location The location of the new need       * @param maxGoal The max goal of the new need       * @param goalType The goal type of the new need +     * @param urgent The urgency of the new need +     * @param description The description of the new need       * @return The need that was created       * @throws IOException Thrown if there was any issue saving the data       * @throws DuplicateKeyException If there already exists a need with the same name       */ -    public Need createNeed(String name, String location, double maxGoal, Need.GoalType goalType, boolean urgent) throws IOException, DuplicateKeyException { +    public Need createNeed(String name, String location, double maxGoal, Need.GoalType goalType, boolean urgent, String description) throws IOException, DuplicateKeyException {          if (maxGoal <= 0) {              throw new IllegalArgumentException("Max Goal must be greater than zero"); @@ -43,7 +46,7 @@ public class CupboardService {              }          } -        Need need = new Need(name, location, maxGoal, goalType, urgent); +        Need need = new Need(name, location, maxGoal, goalType, urgent, description);          return cupboardDAO.addNeed(need);      }  | 
