diff --git a/src/main/java/Controller/SocialMediaController.java b/src/main/java/Controller/SocialMediaController.java index 9aa9b84..2c8586e 100644 --- a/src/main/java/Controller/SocialMediaController.java +++ b/src/main/java/Controller/SocialMediaController.java @@ -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; } @@ -153,6 +155,12 @@ private void updateMessageById(Context context) { } } + private void getAllMessagesByAccountId(Context context) { + int account_id = Integer.parseInt(context.pathParam("account_id")); + List messages = messageService.getAllMessagesByAccountId(account_id); + context.json(messages); + } + private void getAccountTable(Context context) { List accounts = accountService.getAllAccounts(); context.json(accounts);