Skip to content

Conversation

@jueunk617
Copy link
Collaborator

@jueunk617 jueunk617 commented Oct 4, 2025

📌 개요

알림 시스템 와이어프레임 확인 후 발신자 정보 추가 및 전체 테스트 코드 작성


🔨 작업 내용

1. 엔티티 / DTO 수정

  • Notification 엔티티

    • User actor 필드 추가 (발신자 정보)
    • userreceiver 변수명 변경 (수신자 명확화)
    • status 필드 제거 (NotificationRead로 읽음 관리 통일)
    • 모든 정적 팩토리 메서드에 actor 파라미터 추가
  • DTO 추가/수정

    • ActorDto 공통 DTO 생성 (발신자 정보: userId, username, profileImageUrl)
    • 모든 응답 DTO에 ActorDto 추가
    • NotificationCreateRequestactorId 필드 추가

2. Repository 수정

  • NotificationRepositoryImpl
    • 모든 쿼리에서 notification.usernotification.receiver로 변경
    • ROOM 알림 조회를 위해 RoomMember와 LEFT JOIN 추가

3. Service 수정

  • NotificationService
    • 모든 알림 생성 메서드에 actor 파라미터 추가
    • validateActorAndReceiver() 검증 메서드 추가 (자기 자신에게 알림 방지)
    • markAsRead() 강화
      • 접근 권한 검증 (isVisibleToUser)
      • 이미 읽은 알림 체크 시 예외 발생 (NOTIFICATION_ALREADY_READ)

4. Controller 수정

  • NotificationController
    • Request 검증 로직 추가
      • targetType 유효성 검증
      • SYSTEM이 아닌 경우 actorId, targetId 필수 검증

5. 테스트 코드 작성/수정

  • NotificationRepositoryTest : 모든 알림 생성 시 actor 파라미터 추가, ROOM 알림 조회 테스트 통과 확인
  • NotificationServiceTest : actor 추가, 자기 자신에게 알림 전송 시 예외 테스트 추가, 이미 읽은 알림 읽음 처리 시 예외 테스트 수정
  • NotificationWebSocketServiceTest : NotificationWebSocketDto.from() 사용 방식 변경 (Notification 객체 전달)
  • NotificationControllerTest (신규)

🔗 관련 이슈

Closes #155

📝 참고 사항

주요 변경 이유

  • 와이어프레임 요구사항 : "Patrick 님이 댓글을 달았습니다" 같은 발신자 정보 표시 필요
  • 프론트엔드 활용 : actor 정보로 프로필 이미지, 이름 생성 가능
  • 읽음 관리 통일 : status 필드 제거로 시스템 알림의 사용자별 읽음 상태 관리 일관성 확보

아키텍처 개선

  • DTO 레이어 분리 원칙 준수 (ActorDto 사용)
  • User 헬퍼 메서드(getNickname(), getProfileImageUrl()) 활용
  • N+1 문제 방지 (UserProfile fetch 불필요)

주의사항

=> 프로그램 실행 전 Q클래스 재생성 필요 (./gradlew clean compileJava)

✅ 체크리스트

  • 기능 동작 확인
  • 테스트 코드 작성
  • 문서/주석 추가 및 최신화

@jueunk617 jueunk617 self-assigned this Oct 4, 2025
@github-actions github-actions bot changed the title Test: 알림 시스템 기본 인프라 테스트 Test: 알림 시스템 기본 인프라 테스트 (#155) Oct 4, 2025
@namgigun namgigun merged commit d69f3c1 into dev Oct 5, 2025
3 checks passed
@github-actions github-actions bot deleted the Test/155 branch October 5, 2025 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants