diff --git a/src/main/java/org/ntlab/tampoposerver/resources/NotificationsResource.java b/src/main/java/org/ntlab/tampoposerver/resources/NotificationsResource.java index 537a354..e0d2311 100644 --- a/src/main/java/org/ntlab/tampoposerver/resources/NotificationsResource.java +++ b/src/main/java/org/ntlab/tampoposerver/resources/NotificationsResource.java @@ -53,6 +53,18 @@ return Response.ok(notifications).build(); } + @POST + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public Response addNotification(@PathParam("user-id") String userID, @FormParam("from") String from, @FormParam("text") String text, @FormParam("time") String time) { + if (userID == null || userID.isEmpty()) { + var response = Response.status(Response.Status.BAD_REQUEST).entity("404"); + throw new WebApplicationException(response.build()); + } + Notification notification = notificationRepository.addNotification(userID, from, text, time); + return Response.ok(notification).build(); + } + + //通知詳細を取得 @Path("/{notification-id}") @GET @@ -83,6 +95,7 @@ return Response.ok(notification).build(); } + //通知本文だけを返す @Path("/{notification-id}/text") @GET @@ -145,7 +158,7 @@ } Map response = new HashMap<>(); - response.put("time", notification.getText()); + response.put("time", notification.getTime()); return Response.ok(response).build(); } @@ -178,7 +191,7 @@ } Map response = new HashMap<>(); - response.put("from", notification.getText()); + response.put("from", notification.getFrom()); return Response.ok(response).build(); } } \ No newline at end of file