Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: 알림 Entity 구조 변경 #42

Open
wants to merge 50 commits into
base: develop
Choose a base branch
from

Conversation

junest66
Copy link
Collaborator

@junest66 junest66 commented Sep 11, 2024

#️⃣연관된 이슈

CHZZ-94 #done

📝작업 내용

  • 알림 데이터에 auctionId가 필요한 알림 타입이 있어서 기존 Entity 를 추상클래스로 두고, 알림타입마다 상속관계 매핑 구조로 변경하였습니다.
  • NotificationType에 abstract Notification createNotification 추상 메서드를 둬서, 알림 타입을 추가할때 해당 알림 객체를 만드는 메서드를 추가하는 것을 강제하였습니다.
  • 확장성을 위해 추후에 productId 나 다른 정보가 필요한 알림이 있으면, 기존에는 NotifactionEvent, NotificationRealMessage, NotificationSseResponse 를 모두 바꿔야하는 문제가 있었으나, 공통된 필드는 냅두고, 알림 타입마다 다른 필드는 Map<String, Object> additionalFields 에 추가하는 방식으로 변경하였습니다. -> 이를 통해 새로운 알림타입을 만들때 해당 NotifcationType에만 추가하면 됩니다.
  • 실시간 알림 DTO에는 직렬화시 @JsonAnyGetter 를 통해 추가적인 필드가 포함된 Map 데이터를 개별 JSON 필드로 변환하여 동적으로 처리할 수 있습니다.
  • 또한 기존 알림함 조회 쿼리를 상속관계매핑 때문에 부모클래스 QType에서 자식클래스의 필드를 접근하지 못하지만
    (ex: notification.acutionId) 싱글테이블 전략을 사용함으로써 데이터베이스에는 해당 컬럼이 존재하므로 PathBuilder 를 통해 조회합니다.

✅테스트 결과

1. 판매자 낙찰/ 유찰 알림

스크린샷 2024-09-11 오후 5 40 18

2. 미낙찰자 알림

스크린샷 2024-09-11 오후 5 40 26

3. 낙찰자 알림/ 경매시작 알림 / 사전경매 취소 알림

스크린샷 2024-09-11 오후 5 40 35

🙏리뷰 요구사항(선택)

  • 현재 구조에서 개선할점이 있으면 말씀해주세요!
  • 확장성을 생각해서 새로운 필드가 추가된 알림타입이 생긴다면.. 으로 생각해서 구조를 바꿨습니다.

- AuctionRegistrationCanceledNotification -> PreRegistrationCanceledNotification 로 변경

(#94)
@junest66 junest66 self-assigned this Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👨🏻‍💻backend 백엔드 작업 🪄refactor 리팩토링
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants