Skip to content

Commit 85c1187

Browse files
committed
feat: update resource using the service class
Signed-off-by: Otavio Santana <[email protected]>
1 parent 27043f8 commit 85c1187

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/main/java/os/expert/sample/GoalResource.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package os.expert.sample;
22

33

4+
import jakarta.inject.Inject;
45
import jakarta.ws.rs.GET;
56
import jakarta.ws.rs.PUT;
67
import jakarta.ws.rs.Path;
@@ -14,15 +15,27 @@ public class GoalResource {
1415

1516
private static final Logger LOGGER = Logger.getLogger(GoalResource.class.getName());
1617

18+
private final GoalService goalService;
19+
20+
@Inject
21+
public GoalResource(GoalService goalService) {
22+
this.goalService = goalService;
23+
}
24+
25+
@Deprecated
26+
GoalResource() {
27+
this(null);
28+
}
29+
1730
@GET
1831
public List<Goal> goals(@QueryParam("page") int page,@QueryParam("size") int size) {
1932
LOGGER.info("Listing goals, page: " + page + ", size: " + size);
20-
return List.of(new Goal("Learn Quarkus", "Learn Quarkus", List.of(new Task("Create a new project", "Create a new project"))));
33+
return goalService.findGoals(page, size);
2134
}
2235

2336
@PUT
2437
public Goal create(Goal goal) {
2538
LOGGER.info("Creating a goal: " + goal);
26-
return goal;
39+
return goalService.save(goal);
2740
}
2841
}

0 commit comments

Comments
 (0)