Conversation
- 네이밍 일관성을 위해 엔티티는 단수형, 테이블명은 복수형으로 작성함 (cherry picked from commit fd78ebbfbb9da3c77c1aa60f46c19c100b5dced0) # Conflicts: # src/main/generated/com/example/moim/notification/entity/QNotification.java # src/main/generated/com/example/moim/user/entity/QUser.java # src/main/java/com/example/moim/notification/entity/Notifications.java # src/main/java/com/example/moim/user/entity/User.java
(cherry picked from commit 4243cbd83d7ebfe618208cf184dc258fd412d1d6)
(cherry picked from commit 16c7c990b399a1fc010207dd6d96d69c5e4f4ac1)
(cherry picked from commit c7c8f6903cfd69c3fad54dd8f458c823d27bbc67)
(cherry picked from commit 9cbea0dbe4d509aa3141a49c298134a9dcc70dcb)
(cherry picked from commit eb5511c8e0e3b8512b3453e141544d2736b65e5c) # Conflicts: # src/main/java/com/example/moim/notification/controller/NotificationController.java
(cherry picked from commit 877b3f29542ab31d4bb6518853b7de181c93f170) # Conflicts: # .gitignore
(cherry picked from commit 0d8343af1e7ea12119beab94ce3277473ca54857)
(cherry picked from commit 35024db4bf1390077bfefe37b33c1c21e03fd1d9)
- com.google.firebase.messaging.Notification과 중복
- 이미 Notification을 명시한 클래스 안에 있으므로 메서드에서 또 언급할 필요 없음. 의미 중복임.
- 비즈니스 로직과 알림 전송/저장 로직의 책임 분리하여 도메인 로직의 복잡도 낮춤 - 푸시 알림은 외부 호출이라 느릴 수 있어서 비동기로 응답 속도 개선/요청 처리 성능 향상 - 각 이벤트마다 메시지를 하드코딩 하지 않고 템플릿 기반으로 생성하도록 변경
- 근데 테스트 할 때 원래 빌더를 이렇게 많이 썼던가?
| @@ -0,0 +1,37 @@ | |||
| package com.example.moim.notification.entity; | |||
There was a problem hiding this comment.
알림 타입을 ENUM 으로 구현한 것이 한눈에 알림 종류를 볼 수 있어서 깔끔하다고 생각합니다 👍
|
|
||
| @Repository | ||
| @RequiredArgsConstructor | ||
| public class NotificationRepositoryImpl implements |
There was a problem hiding this comment.
이 부분에서 NotificationRepository 로만 기능 구현이 가능할 것 같은데, 왜 NotificationRepositoryImpl 로 분리해서 Override 로 구현하셨는지 궁금합니다!
There was a problem hiding this comment.
테스트를 작성하는 과정에서 필요했어서 이렇게 바꿨는데 지금 결과적으론 안쓰게 되었네요.. 다시 바꾸는게 좋을까요?
There was a problem hiding this comment.
JPA 에서 제공하는 쿼리를 그대로 사용하는 거라면 없어도 될 것 같습니다! 다만 뭔가 커스텀해서 사용하는 거라면 이대로 두는 게 맞는 것 같아요!
| import com.example.moim.notification.entity.NotificationEntity; | ||
| import java.util.List; | ||
|
|
||
| public interface NotificationStrategy<T> { |
There was a problem hiding this comment.
지금 알림 기능 분기 처리한 것이 Strategy 보다는 Handler 라는 네이밍이 더 알맞을 거 같습니다!
Strategy 는 행동 자체가 바뀌어야 사용하는 걸로 알고 있는데(SMS 알림 발송, 메일 알림 발송, 앱 푸시 알림 발송 등등)
저희는 앱 푸시 알림 발송만 사용해서 이벤트/타입에 따른 분기 처리로 보는게 더 알맞을 거 같은데, 이 경우에는 Handler 구조라고 볼 수 있을 거 같습니다!
There was a problem hiding this comment.
제가 놓친 부분을 짚어주셔서 감사해요!! 반영해서 커밋 하겠습니다!!
| void shouldCallFirebaseMessaging_andMarkAsSent() throws FirebaseMessagingException { | ||
| // given | ||
| User user = User.builder().fcmToken("valid_token").build(); | ||
| NotificationEntity notification = NotificationEntity.builder() |
There was a problem hiding this comment.
이게 유효하지 않은 토큰이 들어가는 경우도 있어서 각각 given 부분에 선언을 했어요!
| @DisplayName("사용자에게 읽지 않은 알림이 없으면 false 반환한다") | ||
| void shouldReturnFalseWhenNoUnreadNotifications() { | ||
| // given | ||
| User user = new User(); |
|
|
||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class NotificationEventDispatcher { |
There was a problem hiding this comment.
Handler 패턴으로 알림 구현 하신 점 정말 좋습니다!
배워갑니다 👍
|
앗 확인이 늦었네요! 알림 쪽 복잡했을텐데 수고하셨습니다!! 남의님이 꼼꼼하게 잘 해주셨네요..! |
📌 변경 사항 (What’s changed?)
⚙️ 변경 이유 (Why?)
✅ 테스트 방법 (How to test?)
🤔 기타 참고 사항
💬리뷰 요구사항(선택)