11package clap .server .application .service .notification ;
22
3- import clap .server .adapter .outbound .persistense .entity .notification .NotificationEntity ;
4- import clap .server .adapter .outbound .persistense .repository .notification .NotificationRepository ;
53import clap .server .application .port .inbound .notification .UpdateNotificationUsecase ;
64import clap .server .application .port .outbound .notification .CommandNotificationPort ;
75import clap .server .application .port .outbound .notification .LoadNotificationPort ;
86import clap .server .common .annotation .architecture .ApplicationService ;
97import clap .server .domain .model .notification .Notification ;
8+ import clap .server .exception .ApplicationException ;
9+ import clap .server .exception .code .NotificationErrorCode ;
1010import lombok .RequiredArgsConstructor ;
1111import org .springframework .transaction .annotation .Transactional ;
1212
13- import java .util .Optional ;
14-
1513@ ApplicationService
1614@ RequiredArgsConstructor
17- public class UpdateNotificationService implements UpdateNotificationUsecase {
15+ public class ReadNotificationService implements UpdateNotificationUsecase {
1816
1917 private final LoadNotificationPort loadNotificationPort ;
2018 private final CommandNotificationPort commandNotificationPort ;
@@ -23,7 +21,8 @@ public class UpdateNotificationService implements UpdateNotificationUsecase {
2321 @ Transactional
2422 @ Override
2523 public void updateNotification (Long notificationId ) {
26- Notification notification = loadNotificationPort .findById (notificationId ).get ();
24+ Notification notification = loadNotificationPort .findById (notificationId )
25+ .orElseThrow (() -> new ApplicationException (NotificationErrorCode .NOTIFICATION_NOT_FOUND ));
2726 notification .updateNotificationIsRead ();
2827 commandNotificationPort .save (notification );
2928 }
0 commit comments