-
Notifications
You must be signed in to change notification settings - Fork 4
[refactor] 공지사항 상세 조회 시 북마크 필드 추가 #363
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
Conversation
|
Labeler has applied any labels matching special text in your title and description. |
안내 요약공지사항 상세 조회 응답에 북마크 상태 정보를 추가하도록 NoticeService 및 NoticeDetailResponse를 수정했습니다. BookmarkRepository와 UserService를 주입받아 현재 사용자의 북마크 여부를 확인하고, 응답 DTO에 isBookmark 필드를 추가했으며, 관련 테스트도 업데이트했습니다. 변경 사항
예상 코드 리뷰 난이도🎯 3 (보통) | ⏱️ ~20분 특별히 검토가 필요한 영역:
관련 가능성 있는 PR
제안 리뷰어
시 🐰
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Test Results 37 files 37 suites 11s ⏱️ Results for commit 3463ba0. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/test/java/ku_rum/backend/domain/notice/presentation/NoticeControllerTest.java (1)
138-148: REST Docs에isBookmark필드 문서화를 추가하세요.새로 추가된
isBookmark필드가 REST Docs 응답 필드 문서에 포함되지 않았습니다. API 문서 완성도를 위해 해당 필드에 대한 설명을 추가해야 합니다.🔎 제안하는 수정 사항
responseFields에 새 필드 문서를 추가하세요. Line 146 이전에:.pathParameters( parameterWithName("noticeId").description("조회할 공지사항 ID") ) + .responseFields( + fieldWithPath("code").description("응답 코드"), + fieldWithPath("message").description("응답 메시지"), + fieldWithPath("status").description("상태"), + fieldWithPath("data.id").description("공지사항 ID"), + fieldWithPath("data.content").description("공지 상세 내용(HTML)"), + fieldWithPath("data.link").description("공지 링크"), + fieldWithPath("data.title").description("공지사항 제목"), + fieldWithPath("data.pubdate").description("게시일"), + fieldWithPath("data.isBookmark").description("북마크 여부") + ) .build()
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/main/java/ku_rum/backend/domain/notice/application/NoticeService.java(2 hunks)src/main/java/ku_rum/backend/domain/notice/dto/response/NoticeDetailResponse.java(1 hunks)src/main/resources/config(1 hunks)src/test/java/ku_rum/backend/domain/notice/presentation/NoticeControllerTest.java(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (3)
src/main/resources/config (1)
1-1: 서브모듈 참조 업데이트 — 실제 구현 변경 사항 검증 필요제공된 파일은 서브모듈 커밋 포인터만 업데이트하고 있어서, 실제 구현 코드의 세부 사항을 검토할 수 없습니다. PR 목표에서 언급한 다음 변경 사항들의 정확성을 확인하기 위해 서브모듈의 실제 코드 변경 사항을 검토해야 합니다:
- NoticeService가 BookmarkRepository와 UserService를 올바르게 주입하고 있는지 확인
- NoticeDetailResponse의 isBookmark 필드가 올바르게 구현되었는지 확인
- 북마크 조회 시 사용자 인증/인가 처리가 적절한지 확인 (사용자는 자신의 북마크만 조회 가능해야 함)
- 새로운 서비스 의존성으로 인한 성능 영향 검증
- null 처리 및 엣지 케이스 처리 확인
- 테스트 커버리지 확인
src/main/java/ku_rum/backend/domain/notice/dto/response/NoticeDetailResponse.java (1)
10-11: 북마크 필드 추가가 적절합니다.레코드에
isBookmark필드를 추가하여 공지사항 상세 조회 시 북마크 상태를 응답에 포함할 수 있게 되었습니다.src/main/java/ku_rum/backend/domain/notice/application/NoticeService.java (1)
3-3: 북마크 확인을 위한 의존성 추가가 적절합니다.
BookmarkRepository와UserService를 주입하여 사용자별 북마크 상태를 확인할 수 있게 되었습니다.Also applies to: 11-12, 35-36
| } | ||
|
|
||
| public NoticeDetailResponse findByNoticeId(Long noticeId) { | ||
| User user = userService.getUser(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
find . -type f -name "NoticeService.java" -o -name "NoticeController.java" -o -name "UserService.java" | head -20Repository: KU-rum/backend
Length of output: 285
🏁 Script executed:
cat -n ./src/main/java/ku_rum/backend/domain/notice/application/NoticeService.java | head -80Repository: KU-rum/backend
Length of output: 4328
🏁 Script executed:
cat -n ./src/main/java/ku_rum/backend/domain/user/application/UserService.java | grep -A 30 "getUser()"Repository: KU-rum/backend
Length of output: 4481
🏁 Script executed:
cat -n ./src/main/java/ku_rum/backend/domain/notice/presentation/NoticeController.javaRepository: KU-rum/backend
Length of output: 2574
🏁 Script executed:
find . -type f -name "*SecurityConfig*" -o -name "*Security*.java" | grep -E "(config|security)" | head -20Repository: KU-rum/backend
Length of output: 122
🏁 Script executed:
cat -n ./src/main/java/ku_rum/backend/global/config/SecurityConfig.javaRepository: KU-rum/backend
Length of output: 7919
🏁 Script executed:
find . -type f -name "AuthorizationList.java" -o -name "*AuthorizationList*"Repository: KU-rum/backend
Length of output: 125
🏁 Script executed:
cat -n ./src/main/java/ku_rum/backend/global/config/AuthorizationList.javaRepository: KU-rum/backend
Length of output: 2545
🏁 Script executed:
find . -type f -name "UserUtil.java"Repository: KU-rum/backend
Length of output: 115
🏁 Script executed:
cat -n ./src/main/java/ku_rum/backend/global/utill/UserUtil.javaRepository: KU-rum/backend
Length of output: 1601
🏁 Script executed:
cat -n ./src/main/java/ku_rum/backend/global/security/CustomUserDetails.java | head -40Repository: KU-rum/backend
Length of output: 1784
공지사항 상세 조회 엔드포인트에서 인증되지 않은 사용자 접근 시 예외 발생
/api/v1/notices/{noticeId} 엔드포인트는 AuthorizationList에 /api/v1/notices/**로 등록되어 있어 인증 없이 접근 가능합니다. 그러나 NoticeService.findByNoticeId() 메서드(44줄)에서 userService.getUser()를 무조건 호출하는데, 이는 인증되지 않은 사용자의 SecurityContext에서 CustomUserDetails를 찾지 못해 ClassCastException 또는 NullPointerException을 발생시킵니다.
해결 방법:
- 인증된 사용자인지 확인 후 북마크 여부만 처리하거나
- 엔드포인트 자체에 인증 요구 사항 추가
| boolean isBookmark = true; | ||
| NoticeDetailResponse noticeDetailResponse = new NoticeDetailResponse(noticeId, htmlContent, link, title, LocalDateTime.now(), isBookmark); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
테스트에 isBookmark 필드 검증을 추가하세요.
isBookmark 필드를 생성자에 추가했지만, 응답 검증(assertion)이 누락되었습니다. Line 136 이후에 isBookmark 필드에 대한 검증을 추가해야 합니다.
🔎 제안하는 수정 사항
Line 136 다음에 아래 assertion을 추가하세요:
.andExpect(jsonPath("$.data.pubdate").exists())
+ .andExpect(jsonPath("$.data.isBookmark").value(true))Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In
src/test/java/ku_rum/backend/domain/notice/presentation/NoticeControllerTest.java
around lines 121 to 122 and referencing the assertions area after line 136, the
test constructs NoticeDetailResponse with isBookmark=true but never asserts that
field; add an assertion verifying the response's isBookmark value (e.g.,
assertTrue or assertEquals(true, ...)) immediately after the existing assertions
at line 136 to validate the bookmark flag.
#️⃣ 연관된 이슈
📝작업 내용
작업 상세 내용
공지사항 상세 조회 시 북마크 필드 추가
Summary by CodeRabbit
릴리스 노트
새로운 기능
테스트
✏️ Tip: You can customize this high-level summary in your review settings.