Skip to content

Conversation

@kmw10693
Copy link
Contributor

@kmw10693 kmw10693 commented Dec 19, 2025

#️⃣ 연관된 이슈

📝작업 내용

  • 공지사항 상세 조회 시 북마크 필드 추가

작업 상세 내용

공지사항 상세 조회 시 북마크 필드 추가

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능

    • 공지사항 상세정보 조회 시 북마크 상태 표시 기능 추가
  • 테스트

    • 북마크 상태를 포함한 API 응답 테스트 업데이트

✏️ Tip: You can customize this high-level summary in your review settings.

@kmw10693 kmw10693 requested a review from david-parkk December 19, 2025 01:54
@kmw10693 kmw10693 self-assigned this Dec 19, 2025
@github-actions
Copy link

Labeler has applied any labels matching special text in your title and description.
Please review the labels and make any necessary changes.

@coderabbitai
Copy link

coderabbitai bot commented Dec 19, 2025

안내 요약

공지사항 상세 조회 응답에 북마크 상태 정보를 추가하도록 NoticeService 및 NoticeDetailResponse를 수정했습니다. BookmarkRepository와 UserService를 주입받아 현재 사용자의 북마크 여부를 확인하고, 응답 DTO에 isBookmark 필드를 추가했으며, 관련 테스트도 업데이트했습니다.

변경 사항

응집 / 파일(들) 변경 요약
북마크 지원 추가
src/main/java/ku_rum/backend/domain/notice/application/NoticeService.java
BookmarkRepository 및 UserService 의존성 주입, 현재 사용자 조회 후 북마크 존재 여부 확인 로직 추가, NoticeDetailResponse 생성자에 isBookmark 플래그 전달
응답 DTO 필드 추가
src/main/java/ku_rum/backend/domain/notice/dto/response/NoticeDetailResponse.java
레코드에 boolean 타입의 isBookmark 컴포넌트 추가로 생성자 서명 변경 (5개 → 6개 파라미터)
테스트 코드 업데이트
src/test/java/ku_rum/backend/domain/notice/presentation/NoticeControllerTest.java
NoticeDetailResponse 생성자 호출에 isBookmark 파라미터 추가
서브모듈 참조 업데이트
src/main/resources/config
서브모듈 커밋 참조 업데이트 (b9a38aae → 69b265ae)

예상 코드 리뷰 난이도

🎯 3 (보통) | ⏱️ ~20분

특별히 검토가 필요한 영역:

  • NoticeService의 UserService 호출 및 null 처리 로직 (현재 사용자 미존재 시 처리 방식)
  • BookmarkRepository 존재성 검사 로직의 성능 (N+1 쿼리 문제 여부)
  • NoticeDetailResponse 생성자 서명 변경에 따른 다른 호출 지점 누락 확인

관련 가능성 있는 PR

  • [Feat] 북마크 API #320: 이 PR의 북마크 로직 및 NoticeDetailResponse 생성자 변경과 직접 관련된 북마크 도메인 및 BookmarkRepository/NoticeService 수정 사항을 다룸
  • [Feat] 공지사항 API 링크 추가 #328: 동일한 NoticeDetailResponse 레코드를 수정하고 NoticeService 호출 지점에 추가 필드를 전달하는 공통 변경 사항 포함
  • [FEAT] 공지사항 상세 조회 #316: NoticeDetailResponse/NoticeService 상세 조회 기능을 도입한 동일 영역의 관련 변경 사항 포함

제안 리뷰어

  • david-parkk

시 🐰

북마크 플래그가 피어나고,
서비스에 의존성 심어지니,
사용자의 선호를 담은 응답,
한 발 더 나아가는 공지 기능,
토끼가 축하하는 이 변화! 🎉

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning PR 설명이 필수 섹션을 포함하지만 불완전합니다. 연관 이슈가 명시되지 않았고, 작업 상세 내용이 작업 내용과 중복되어 충분하지 않습니다. 연관 이슈 번호를 추가하고, 작업 상세 내용에서 변경된 파일, 기술적 구현 방식, 그리고 리뷰 요구사항을 구체적으로 작성해주세요.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 주요 변경 사항을 명확하게 요약합니다. 공지사항 상세 조회에 북마크 필드 추가라는 핵심 변경 내용을 간결하고 구체적으로 설명합니다.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/bookmark-check

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Dec 19, 2025

Test Results

 37 files   37 suites   11s ⏱️
150 tests 150 ✅ 0 💤 0 ❌
151 runs  151 ✅ 0 💤 0 ❌

Results for commit 3463ba0.

♻️ This comment has been updated with latest results.

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between dab4b4c and 4fdf4e7.

📒 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: 북마크 확인을 위한 의존성 추가가 적절합니다.

BookmarkRepositoryUserService를 주입하여 사용자별 북마크 상태를 확인할 수 있게 되었습니다.

Also applies to: 11-12, 35-36

}

public NoticeDetailResponse findByNoticeId(Long noticeId) {
User user = userService.getUser();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

find . -type f -name "NoticeService.java" -o -name "NoticeController.java" -o -name "UserService.java" | head -20

Repository: KU-rum/backend

Length of output: 285


🏁 Script executed:

cat -n ./src/main/java/ku_rum/backend/domain/notice/application/NoticeService.java | head -80

Repository: 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.java

Repository: KU-rum/backend

Length of output: 2574


🏁 Script executed:

find . -type f -name "*SecurityConfig*" -o -name "*Security*.java" | grep -E "(config|security)" | head -20

Repository: KU-rum/backend

Length of output: 122


🏁 Script executed:

cat -n ./src/main/java/ku_rum/backend/global/config/SecurityConfig.java

Repository: 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.java

Repository: 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.java

Repository: KU-rum/backend

Length of output: 1601


🏁 Script executed:

cat -n ./src/main/java/ku_rum/backend/global/security/CustomUserDetails.java | head -40

Repository: KU-rum/backend

Length of output: 1784


공지사항 상세 조회 엔드포인트에서 인증되지 않은 사용자 접근 시 예외 발생

/api/v1/notices/{noticeId} 엔드포인트는 AuthorizationList/api/v1/notices/**로 등록되어 있어 인증 없이 접근 가능합니다. 그러나 NoticeService.findByNoticeId() 메서드(44줄)에서 userService.getUser()를 무조건 호출하는데, 이는 인증되지 않은 사용자의 SecurityContext에서 CustomUserDetails를 찾지 못해 ClassCastException 또는 NullPointerException을 발생시킵니다.

해결 방법:

  • 인증된 사용자인지 확인 후 북마크 여부만 처리하거나
  • 엔드포인트 자체에 인증 요구 사항 추가

Comment on lines +121 to +122
boolean isBookmark = true;
NoticeDetailResponse noticeDetailResponse = new NoticeDetailResponse(noticeId, htmlContent, link, title, LocalDateTime.now(), isBookmark);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

테스트에 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants