Skip to content

Commit

Permalink
feat: update goal with list instead of int
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <[email protected]>
  • Loading branch information
otaviojava committed Dec 1, 2024
1 parent 13361f6 commit e846d04
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/main/java/os/expert/sample/Goal.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
package os.expert.sample;

import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.json.bind.annotation.JsonbPropertyOrder;
import jakarta.nosql.Column;
import jakarta.nosql.Entity;
import jakarta.nosql.Id;

import java.util.List;

@JsonbPropertyOrder({"id", "title", "description", "priority", "tasks"})
@Entity
public record Goal(@Id String title, @Column String description, @Column int priority, @Column List<Task> tasks) {
public record Goal(
@Id @JsonbProperty("id") String id,
@JsonbProperty("title") @Column String title,
@JsonbProperty("description") @Column String description,
@JsonbProperty("priority") @Column int priority,
@JsonbProperty("tasks") @Column List<String> tasks) {

}
8 changes: 7 additions & 1 deletion src/main/java/os/expert/sample/GoalResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@


import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DefaultValue;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;

import java.util.List;
import java.util.logging.Logger;

@Path("/goals")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class GoalResource {

private static final Logger LOGGER = Logger.getLogger(GoalResource.class.getName());
Expand All @@ -35,7 +41,7 @@ public List<Goal> goals(@QueryParam("page") @DefaultValue("1") int page,
return goalService.findGoals(page, size);
}

@PUT
@POST
public Goal create(Goal goal) {
LOGGER.info("Creating a goal: " + goal);
return goalService.save(goal);
Expand Down

0 comments on commit e846d04

Please sign in to comment.