33import com .api .ttoklip .domain .common .comment .Comment ;
44import com .api .ttoklip .domain .honeytip .post .domain .HoneyTip ;
55import com .api .ttoklip .domain .member .domain .Member ;
6+ import com .api .ttoklip .domain .member .service .MemberService ;
67import com .api .ttoklip .domain .notification .dto .response .NotificationFrontResponse ;
78import com .api .ttoklip .domain .notification .dto .response .NotificationFrontResponses ;
89import com .api .ttoklip .domain .notification .entity .NotiCategory ;
1617import java .util .List ;
1718import lombok .RequiredArgsConstructor ;
1819import lombok .extern .slf4j .Slf4j ;
20+ import org .springframework .data .domain .Pageable ;
1921import org .springframework .stereotype .Service ;
2022import org .springframework .transaction .annotation .Transactional ;
2123
@@ -26,6 +28,7 @@ public class NotificationService {
2628
2729 private final NotificationRepository notificationRepository ;
2830 private final NotificationRepositoryImpl notificationRepositoryImpl ;
31+ private final MemberService memberService ;
2932
3033 @ Transactional
3134 public void register (final NotiCategory notiCategory , final Member member , final Long targetClassId ,
@@ -64,15 +67,19 @@ private String getTargetType(Object target) {
6467 throw new ApiException (ErrorType ._BAD_CATEGORY_NOTIFICATION_TYPE );
6568 }
6669
70+ public NotificationFrontResponses findNotification (final Long currentMemberId , final Pageable pageRequest ) {
71+ Member currentMember = memberService .findById (currentMemberId );
6772
68- public NotificationFrontResponses findNotificationByCategory ( final String value ) {
69- NotiCategory category = NotiCategory . getNotificationByCategory ( value );
70- List < Notification > top5RecentNotifications = notificationRepositoryImpl . findTop5RecentNotifications ( category );
73+ List < Notification > top5RecentNotifications = notificationRepositoryImpl . findTop5RecentNotifications (
74+ currentMember . getId (), pageRequest
75+ );
7176
7277 List <NotificationFrontResponse > responses = top5RecentNotifications .stream ()
73- .map (noti -> NotificationFrontResponse .of (noti .getId (), noti .getTargetIndex (), noti .getTargetType (),
74- noti .getTitle (),
75- noti .getText (), noti .isStatus ())).toList ();
78+ .map (noti -> NotificationFrontResponse .of (
79+ noti .getId (), noti .getTargetIndex (), noti .getTargetType (),
80+ noti .getTitle (), noti .getText (), noti .isStatus ()
81+ )
82+ ).toList ();
7683
7784 return NotificationFrontResponses .from (responses );
7885 }
0 commit comments