Skip to content

Commit 3520de2

Browse files
committed
feat: 알림 클릭 시 게시물 이동 기능 추가(#45)
1 parent 3238244 commit 3520de2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/java/com/dmu/debug_visual/community/service/CommentService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.dmu.debug_visual.user.User;
77
import lombok.RequiredArgsConstructor;
88
import org.springframework.stereotype.Service;
9+
import org.springframework.transaction.annotation.Transactional;
910

1011
import java.util.List;
1112
import java.util.stream.Collectors;
@@ -20,7 +21,7 @@ public class CommentService {
2021

2122
Comment parent = null;
2223

23-
@Transactional // ✨ 알림 생성까지 하나의 트랜잭션으로 묶어주는 것이 안전합니다.
24+
@Transactional
2425
public Long createComment(CommentRequestDTO dto, User user) {
2526
Post post = postRepository.findById(dto.getPostId())
2627
.orElseThrow(() -> new RuntimeException("게시글 없음"));
@@ -43,22 +44,21 @@ public Long createComment(CommentRequestDTO dto, User user) {
4344
builder.parent(parent);
4445

4546
if (!user.getUserNum().equals(parent.getWriter().getUserNum())) {
46-
// 대댓글 알림 시 postId 추가
47+
// 대댓글 알림 시 postId 추가
4748
notificationService.notify(
4849
parent.getWriter(),
4950
user.getName() + "님이 댓글에 답글을 남겼습니다.",
50-
post.getId() // 게시물 ID 전달
51+
post.getId() // 게시물 ID 전달
5152
);
5253
}
5354
}
5455

5556
// 게시글 작성자에게 알림 (작성자 본인이 아닌 경우)
5657
if (!user.getUserNum().equals(post.getWriter().getUserNum())) {
57-
// ✨ 게시글 댓글 알림 시 postId 추가
5858
notificationService.notify(
5959
post.getWriter(),
6060
user.getName() + "님이 게시글에 댓글을 남겼습니다.",
61-
post.getId() // ✨ 게시물 ID 전달
61+
post.getId()
6262
);
6363
}
6464

0 commit comments

Comments
 (0)