Conversation
Walkthrough저장된 푸드트럭 조회 페이징에서 커서 키를 Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Service as SavedFoodTruckService
participant Repo as SavedFoodTruckRepository
participant DTO as SavedFoodTruckResponse
participant Paging as CursorPagingResponse
User->>Service: getSavedFoodTrucks(member, cursor, size)
Service->>Repo: findMemberSavedFoodTruckWithCursor(member, cursor, size)
Repo-->>Service: Slice<SavedFoodTruck>
par Build responses & count
Service->>DTO: SavedFoodTruck → SavedFoodTruckResponse (savedFoodTruckId 포함)
Service->>Repo: countByMemberAndFoodTruckViewedStatus(member, ON)
Repo-->>Service: totalSize (long)
end
Service->>Paging: of(responses, SavedFoodTruckResponse::savedFoodTruckId, hasNext, totalSize)
Paging-->>Service: CursorPagingResponse{content, lastCursor, hasNext, totalSize}
Service-->>User: CursorPagingResponse<SavedFoodTruckResponse>
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (3)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/main/java/konkuk/chacall/domain/member/application/foodtruck/SavedFoodTruckService.java(1 hunks)src/main/java/konkuk/chacall/domain/member/domain/repository/SavedFoodTruckRepository.java(1 hunks)src/main/java/konkuk/chacall/domain/member/presentation/dto/response/SavedFoodTruckResponse.java(3 hunks)src/main/java/konkuk/chacall/global/common/dto/CursorPagingResponse.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 (6)
src/main/java/konkuk/chacall/domain/member/domain/repository/SavedFoodTruckRepository.java (1)
62-66: LGTM! 전체 개수 조회 메서드가 올바르게 추가되었습니다.페이징 응답에 totalSize를 제공하기 위한 count 쿼리 메서드가 적절하게 구현되었습니다. JPQL 쿼리 문법과 메서드 시그니처 모두 올바릅니다.
src/main/java/konkuk/chacall/domain/member/application/foodtruck/SavedFoodTruckService.java (1)
67-70: 커서 키 불일치 문제가 올바르게 해결되었습니다.
SavedFoodTruckResponse::savedFoodTruckId를 커서 추출자로 사용하여 페이징 커서 불일치 문제가 해결되었고, totalSize를 응답에 포함시켜 프론트엔드 요구사항도 충족되었습니다.성능 고려사항: 매 페이지 요청마다 count 쿼리가 실행됩니다. 저장된 푸드트럭 수가 많은 사용자의 경우 성능에 영향을 줄 수 있습니다. 필요시 캐싱을 고려해볼 수 있습니다.
src/main/java/konkuk/chacall/domain/member/presentation/dto/response/SavedFoodTruckResponse.java (2)
27-29: 커서 계산을 위한 필드 추가가 적절합니다.
savedFoodTruckId를 응답에 포함하되 JSON에서는 숨김 처리하는 접근 방식이 올바릅니다. 다만, Line 7의 JsonIgnore import를 Jackson 어노테이션으로 수정해야 정상 동작합니다.
31-43: Factory 메서드 변경이 올바르게 구현되었습니다.
SavedFoodTruck을 직접 받아서savedFoodTruckId를 추출하는 방식으로 변경되어, 커서 페이징에 필요한 ID를 정확하게 전달할 수 있게 되었습니다.src/main/java/konkuk/chacall/global/common/dto/CursorPagingResponse.java (2)
5-10: LGTM! totalSize 필드가 적절하게 추가되었습니다.
Long타입으로 nullable하게 설계되어 하위 호환성이 유지되며, 프론트엔드 요구사항을 충족합니다.
11-27: 메서드 오버로딩을 통한 하위 호환성 유지가 우수합니다.기존 메서드를 유지하면서 새로운 totalSize 파라미터를 지원하는 오버로드를 추가하여, 다른 코드의 변경 없이 기능을 확장할 수 있도록 설계되었습니다.
| import konkuk.chacall.domain.foodtruck.domain.model.FoodTruck; | ||
| import konkuk.chacall.domain.foodtruck.domain.value.FoodTruckInfo; | ||
| import konkuk.chacall.domain.member.domain.SavedFoodTruck; | ||
| import net.minidev.json.annotate.JsonIgnore; |
There was a problem hiding this comment.
잘못된 JsonIgnore 어노테이션 import를 수정해야 합니다.
net.minidev.json.annotate.JsonIgnore는 json-smart 라이브러리의 어노테이션으로, Spring Boot의 기본 JSON 직렬화 라이브러리인 Jackson에서는 동작하지 않습니다. 이로 인해 savedFoodTruckId가 API 응답에 노출될 수 있습니다.
다음과 같이 수정하세요:
-import net.minidev.json.annotate.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnore;🤖 Prompt for AI Agents
In
src/main/java/konkuk/chacall/domain/member/presentation/dto/response/SavedFoodTruckResponse.java
around line 7, the class imports net.minidev.json.annotate.JsonIgnore which is
from json-smart and not recognized by Spring Boot's Jackson serializer; replace
that import with com.fasterxml.jackson.annotation.JsonIgnore (and ensure the
savedFoodTruckId field is annotated with @JsonIgnore) so Jackson will correctly
omit the field from API responses.
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check for existing Jackson imports in the codebase to confirm Jackson usage
rg -n "import com.fasterxml.jackson" --type java -C 1 | head -30
# Check for any other JsonIgnore usage in the project
rg -n "@JsonIgnore" --type java -C 2
# Check build file to confirm Jackson dependency
fd -e gradle -e xml | xargs grep -l "jackson\|spring-boot-starter-web" | head -5
Length of output: 3393
@ksg1227 네, 확인했습니다! CodeRabbit의 지적이 정확합니다. 이 부분은 반드시 수정이 필요합니다. 🔴
문제 확인 결과
코드베이스 전체를 검색한 결과:
- 프로젝트는 Jackson을 JSON 직렬화 라이브러리로 사용 중입니다 (
com.fasterxml.jackson패키지의 어노테이션들이 여러 파일에서 사용됨) - 현재
SavedFoodTruckResponse.java가 유일하게@JsonIgnore를 사용하는 파일입니다 - 하지만 잘못된 라이브러리에서 import하고 있습니다 (
net.minidev.json.annotate.JsonIgnore)
왜 문제인가요?
json-smart 라이브러리의 JsonIgnore는 Jackson에서 인식되지 않기 때문에, savedFoodTruckId가 실제 API 응답에 노출됩니다. 이는 커서 계산용 내부 필드이므로 클라이언트에게 노출되어서는 안 됩니다.
수정 방법
-import net.minidev.json.annotate.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnore;이렇게 수정하시면 Jackson이 @JsonIgnore 어노테이션을 정상적으로 인식하고, savedFoodTruckId 필드가 API 응답에서 제외됩니다.
There was a problem hiding this comment.
흠 스웨거 상에서는 응답이 안보이는걸로 확인하긴했는데 그래도 jackson 사용으로 일관성을 맞추는게 좋아보이네요! 수정하겠습니다~
There was a problem hiding this comment.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
ksg1227
left a comment
There was a problem hiding this comment.
확인했습니다! 코래 코멘트 확인 한 번만 부탁드려요~
#️⃣연관된 이슈
📝작업 내용
스크린샷 (선택)
💬리뷰 요구사항(선택)
Summary by CodeRabbit
릴리스 노트
기능 개선
리팩토링
추가