Skip to content

fix: 알림 조회 API Jackson 직렬화 오류 수정 (#52)#53

Merged
1anminJ merged 1 commit intomainfrom
fix/comment-notification
Oct 20, 2025
Merged

fix: 알림 조회 API Jackson 직렬화 오류 수정 (#52)#53
1anminJ merged 1 commit intomainfrom
fix/comment-notification

Conversation

@1anminJ
Copy link
Copy Markdown
Contributor

@1anminJ 1anminJ commented Oct 20, 2025

📋 PR 개요

GET /api/notifications API 호출 시 하이버네이트 지연 로딩 프록시 객체로 인해 발생하던 Jackson JSON 직렬화 오류 (InvalidDefinitionException)를 해결합니다. 엔티티 대신 DTO를 사용하도록 수정하고 관련 코드를 정리합니다.


💻 주요 변경 사항

  • NotificationResponse DTO 추가:

    • 알림 목록 API 응답에 사용될 NotificationResponse DTO 클래스를 생성했습니다.
    • 엔티티를 DTO로 변환하는 fromEntity 정적 팩토리 메소드를 포함합니다.
  • NotificationService 수정:

    • getUserNotifications 메소드의 반환 타입을 List<Notification>에서 List<NotificationResponse>로 변경하고, 내부에서 DTO 변환 로직을 수행하도록 수정했습니다.
    • markAsRead 메소드에 @Transactional을 추가하고 코드를 정리했습니다.
    • 전체적인 코드 가독성 향상을 위해 주석 추가 및 포맷팅을 진행했습니다.
  • NotificationController 수정:

    • getMyNotifications 메소드의 반환 타입을 ResponseEntity<List<NotificationResponse>>로 변경하여 DTO를 반환하도록 수정했습니다.
    • markAsRead 메소드의 반환 타입을 ResponseEntity<Void>로 변경했습니다.
    • Swagger 어노테이션 (@ApiResponses, @Parameter, @SecurityRequirement 등)을 추가/개선하여 API 문서를 명확하게 했습니다.
    • 전체적인 코드 가독성 향상을 위해 주석 추가 및 포맷팅을 진행했습니다.

🔗 관련 이슈

@1anminJ 1anminJ merged commit 8319e4b into main Oct 20, 2025
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.

[BUG] 알림 목록 조회(GET /api/notifications) 시 500 에러 (Jackson 직렬화 오류)

1 participant