Conversation
Walkthrough친구 검색 응답에 상대가 보낸(수신된) 친구 요청 여부를 포함하도록 서비스, 저장소, DTO, 컨트롤러 및 관련 테스트/문서가 업데이트되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
actor User as 사용자
participant Controller as FriendQueryController
participant Service as FriendQueryService
participant Repository as FriendRepository
participant DB as Database
User->>Controller: GET /friends/search?nickname=xxx
Controller->>Service: searchByNickname(nickname, userId)
Service->>Repository: findByNicknameContains(nickname)
Repository-->>Service: matchedUsers
Service->>Repository: findFromUserIdsByToUserAndStatus(userId, matchedUserIds, PENDING)
Repository->>DB: SELECT f.fromUser.id WHERE to_user = userId AND from_user IN (matchedUserIds) AND status = PENDING
DB-->>Repository: receivedRequestUserIds
Repository-->>Service: receivedRequestUserIds
Service->>Repository: (existing) findFromUserIdsByFromUserAndStatus(userId, matchedUserIds, PENDING)
Repository-->>Service: sentRequestUserIds
Service->>Service: map results -> FriendSearchResponse(requestSent, requestReceived, isFriend)
Service-->>Controller: List<FriendSearchResponse>
Controller-->>User: BaseResponse<List<FriendSearchResponse>>
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 38 files 38 suites 12s ⏱️ Results for commit f8a5be7. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Actionable comments posted: 1
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/friend/presentation/FriendQueryControllerTest.java (1)
195-198:⚠️ Potential issue | 🟠 Major두 번째
responseFields()호출이 첫 번째를 덮어쓰므로, 첫 번째 호출을 제거하세요.Line 195-197의
responseFields(RestDocsFieldSnippets.COMMON_RESPONSE_FIELDS)는 불필요합니다.RestDocsFieldSnippets.withDataFields()가 이미COMMON_RESPONSE_FIELDS_WITH_DATA(code, status, message, data 포함)를 반환하므로, 중복된 필드 정의가 발생합니다. REST Docs 빌더에서responseFields()를 두 번 호출하면 두 번째 호출이 첫 번째를 덮어씁니다.getFriendList(),getReceivedFriendRequests()와 같은 다른 테스트 메서드들과 일관성 있게withDataFields()만 사용하세요.♻️ 제안: 중복 호출 제거
.responseFields( - RestDocsFieldSnippets.COMMON_RESPONSE_FIELDS - ) - .responseFields(RestDocsFieldSnippets.withDataFields(List.of( + RestDocsFieldSnippets.withDataFields(List.of( fieldWithPath("data[].userId").type(JsonFieldType.NUMBER).description("유저 ID"), fieldWithPath("data[].nickname").type(JsonFieldType.STRING).description("유저 닉네임"), fieldWithPath("data[].imageUrl").type(JsonFieldType.STRING).description("프로필 이미지 URL"),
🤖 Fix all issues with AI agents
In
`@src/test/java/ku_rum/backend/domain/friend/presentation/FriendQueryControllerTest.java`:
- Around line 57-58: Replace the hardcoded real-looking JWT in the Authorization
header in FriendQueryControllerTest.java with a clearly dummy value or a shared
constant (e.g., "Bearer test-token" or TEST_AUTH_TOKEN) to avoid Gitleaks flags;
locate the header call that sets "Authorization" (the .header("Authorization",
"...") call around the test HTTP request) and change the string to the dummy
token or refactor it to a test constant used by both occurrences (the lines
around 57-58 and the similar block at 96-97).
🧹 Nitpick comments (1)
src/main/java/ku_rum/backend/domain/friend/application/FriendQueryService.java (1)
88-106:List.contains()호출을Set기반으로 변경하면 성능이 개선됩니다.
sentRequestUserIds,receivedRequestUserIds,friendUserIds모두List인 상태에서.contains()를 반복 호출하고 있어 O(n×m) 복잡도입니다.HashSet으로 변환하면 O(n+m)으로 줄일 수 있습니다. 기존 코드도 같은 패턴이므로 이번 PR 범위가 아니라면 후속으로 처리해도 됩니다.♻️ 제안
- List<Long> sentRequestUserIds = friendRepository.findToUserIdsByFromUserAndStatus(currentUser.getId(), - targetUserIds, FriendStatus.PENDING); + Set<Long> sentRequestUserIds = new HashSet<>(friendRepository.findToUserIdsByFromUserAndStatus(currentUser.getId(), + targetUserIds, FriendStatus.PENDING)); - List<Long> receivedRequestUserIds = friendRepository.findFromUserIdsByToUserAndStatus(currentUser.getId(), - targetUserIds, FriendStatus.PENDING); + Set<Long> receivedRequestUserIds = new HashSet<>(friendRepository.findFromUserIdsByToUserAndStatus(currentUser.getId(), + targetUserIds, FriendStatus.PENDING)); - List<Long> friendUserIds = friendRepository.findFriendUserIds(currentUser.getId(), targetUserIds, - FriendStatus.ACCEPT); + Set<Long> friendUserIds = new HashSet<>(friendRepository.findFriendUserIds(currentUser.getId(), targetUserIds, + FriendStatus.ACCEPT));
src/test/java/ku_rum/backend/domain/friend/presentation/FriendQueryControllerTest.java
Outdated
Show resolved
Hide resolved
- mock test 전환
|
There was a problem hiding this comment.
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/friend/presentation/FriendQueryControllerTest.java (1)
205-208:⚠️ Potential issue | 🟡 Minor
.responseFields()가 두 번 호출되어 첫 번째 호출이 무시됩니다.
ResourceSnippetParameters.builder()에서responseFields()를 두 번 호출하면 두 번째 호출이 첫 번째를 덮어씁니다. Line 206의COMMON_RESPONSE_FIELDS는 효과가 없는 코드입니다.withDataFields()가 이미 공통 필드를 포함하므로 결과적으로 문서에는 문제가 없지만, 혼란을 줄 수 있으므로 제거하는 것이 좋습니다.제안
.responseFields( - RestDocsFieldSnippets.COMMON_RESPONSE_FIELDS - ) - .responseFields(RestDocsFieldSnippets.withDataFields(List.of( + RestDocsFieldSnippets.withDataFields(List.of( fieldWithPath("data[].userId").type(JsonFieldType.NUMBER).description("유저 ID"),
🧹 Nitpick comments (2)
src/test/java/ku_rum/backend/domain/friend/presentation/FriendQueryControllerTest.java (2)
36-37: 주석 처리된@SpringBootTest제거 필요.
@WebMvcTest로 마이그레이션이 완료되었으므로, 주석 처리된@SpringBootTest는 제거하는 것이 좋습니다.-//@SpringBootTest `@WebMvcTest`(FriendQueryController.class)
163-171:getSentRequests에서RestDocsFieldSnippets.withDataFields()헬퍼를 사용하지 않고 있습니다.다른 테스트들은
withDataFields()를 통해 공통 응답 필드를 포함하는데, 이 테스트만 수동으로message,status,code를 나열하고 있습니다. 일관성을 위해 동일한 패턴을 사용하는 것이 좋습니다.



#️⃣ 연관된 이슈
closes #426
📝작업 내용
작업 상세 내용
클라이언트 UI 개선과 관련한 필드 추가
💬리뷰 요구사항
Summary by CodeRabbit
새로운 기능
문서
테스트