diff --git a/src/main/java/com/example/spot/domain/Notification.java b/src/main/java/com/example/spot/domain/Notification.java index 423ba33a..3d7b96b4 100644 --- a/src/main/java/com/example/spot/domain/Notification.java +++ b/src/main/java/com/example/spot/domain/Notification.java @@ -37,6 +37,9 @@ public class Notification extends BaseEntity { @Column(nullable = false) private String notifierName; + @Column(nullable = true) + private Long studyPostId; + //== 회원 ==// @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "member_id", nullable = false) diff --git a/src/main/java/com/example/spot/service/notification/NotificationQueryServiceImpl.java b/src/main/java/com/example/spot/service/notification/NotificationQueryServiceImpl.java index 54f2aec2..316508ec 100644 --- a/src/main/java/com/example/spot/service/notification/NotificationQueryServiceImpl.java +++ b/src/main/java/com/example/spot/service/notification/NotificationQueryServiceImpl.java @@ -94,6 +94,8 @@ public NotificationListDTO getAllNotifications(Long memberId, Pageable pageable) .notificationId(notification.getId()) .createdAt(notification.getCreatedAt()) .type(notification.getType()) + .studyId(notification.getStudy().getId()) + .studyPostId(notification.getStudyPostId()) .studyTitle(notification.getStudy().getTitle()) .studyProfileImage(notification.getStudy().getProfileImage()) .notifierName(notification.getNotifierName()) // 알림 생성한 회원 이름 diff --git a/src/main/java/com/example/spot/service/studypost/StudyPostCommandServiceImpl.java b/src/main/java/com/example/spot/service/studypost/StudyPostCommandServiceImpl.java index 539d1146..ef8e88b5 100644 --- a/src/main/java/com/example/spot/service/studypost/StudyPostCommandServiceImpl.java +++ b/src/main/java/com/example/spot/service/studypost/StudyPostCommandServiceImpl.java @@ -135,12 +135,13 @@ public StudyPostResDTO.PostPreviewDTO createPost(Long studyId, StudyPostRequestD // 알림 생성 for (Member studyMember : members) { Notification notification = Notification.builder() - .study(studyPost.getStudy()) - .member(studyMember) - .notifierName(member.getName()) // 글을 작성한 회원 이름 - .type(NotifyType.ANNOUNCEMENT) - .isChecked(false) - .build(); + .study(studyPost.getStudy()) + .member(studyMember) + .studyPostId(studyPost.getId()) + .notifierName(member.getName()) // 글을 작성한 회원 이름 + .type(NotifyType.ANNOUNCEMENT) + .isChecked(false) + .build(); notificationRepository.save(notification); } } diff --git a/src/main/java/com/example/spot/web/dto/notification/NotificationResponseDTO.java b/src/main/java/com/example/spot/web/dto/notification/NotificationResponseDTO.java index 1164addc..ff47857b 100644 --- a/src/main/java/com/example/spot/web/dto/notification/NotificationResponseDTO.java +++ b/src/main/java/com/example/spot/web/dto/notification/NotificationResponseDTO.java @@ -26,6 +26,8 @@ public static class NotificationListDTO { @AllArgsConstructor public static class NotificationDTO{ Long notificationId; + Long studyId; + Long studyPostId; String studyTitle; String studyProfileImage; String notifierName;