Skip to content

Commit

Permalink
get all messages by account id endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jmsundin committed Jan 31, 2024
1 parent 59b4ee8 commit 5693b5d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/Controller/SocialMediaController.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public Javalin startAPI() {
app.patch("/messages/{message_id}", this::updateMessageById);
app.delete("/messages/{message_id}", this::deleteMessageById);

app.get("/accounts/{account_id}/messages", this::getAllMessagesByAccountId);

return app;
}

Expand Down Expand Up @@ -153,6 +155,12 @@ private void updateMessageById(Context context) {
}
}

private void getAllMessagesByAccountId(Context context) {
int account_id = Integer.parseInt(context.pathParam("account_id"));
List<Message> messages = messageService.getAllMessagesByAccountId(account_id);
context.json(messages);
}

private void getAccountTable(Context context) {
List<Account> accounts = accountService.getAllAccounts();
context.json(accounts);
Expand Down

0 comments on commit 5693b5d

Please sign in to comment.