Skip to content

[FIX] 저장 푸드트럭 조회시 페이징 관련 이슈 해결#58

Merged
buzz0331 merged 3 commits intodevelopfrom
fix/#57-paging-issue
Nov 1, 2025
Merged

[FIX] 저장 푸드트럭 조회시 페이징 관련 이슈 해결#58
buzz0331 merged 3 commits intodevelopfrom
fix/#57-paging-issue

Conversation

@buzz0331
Copy link
Contributor

@buzz0331 buzz0331 commented Nov 1, 2025

#️⃣연관된 이슈

📝작업 내용

  • 기존에 savedFoodTruckId로 커서 키를 잡고 쿼리를 호출하는데 프론트에게 반환할때는 foodTruckId로 반환해서 뒷 페이지에서는 페이징 조회가 안되는 이슈를 해결했습니다.
  • 추가적으로 프론트 요청에 따라 전체 데이터 갯수를 조회해야 하는 요구사항으로 인해 CursorPagingResponse에 totalSize 변수를 추가하고 of를 오버로딩하여 처리하였습니다.

스크린샷 (선택)

💬리뷰 요구사항(선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요?

Summary by CodeRabbit

릴리스 노트

  • 기능 개선

    • 저장된 푸드트럭 목록 조회에 전체 항목 수(totalSize) 메타데이터 추가
    • 페이징 키가 저장된 항목 기준으로 작동하도록 변경
  • 리팩토링

    • 저장된 푸드트럭에서 직접 응답 생성하도록 조회 흐름 간소화
    • 페이징 응답 구조 확장으로 총계 정보 지원
  • 추가

    • 회원별 저장된 푸드트럭 총계 조회 기능 추가

@coderabbitai
Copy link

coderabbitai bot commented Nov 1, 2025

Walkthrough

저장된 푸드트럭 조회 페이징에서 커서 키를 foodTruckId에서 savedFoodTruckId로 변경하고, 전체 개수(totalSize)를 조회해 페이징 응답에 포함하도록 서비스·리포지토리·DTO·페이징 응답을 수정합니다.

Changes

Cohort / File(s) 변경 요약
저장소 쿼리 메서드 추가
\src/main/java/konkuk/chacall/domain/member/domain/repository/SavedFoodTruckRepository.java``
countByMemberAndFoodTruckViewedStatus(User, FoodTruckViewedStatus) 메서드 추가(회원 + 조회 상태로 저장된 푸드트럭 총수 반환)
응답 DTO 구조 개선
\src/main/java/konkuk/chacall/domain/member/presentation/dto/response/SavedFoodTruckResponse.java``
savedFoodTruckId 필드 추가(@JsonIgnore, Swagger 숨김), 팩토리 메서드 시그니처 변경: of(SavedFoodTruck)로 전환하고 내부적으로 savedFoodTruck.getFoodTruck() 사용
페이징 응답 프레임워크 확장
\src/main/java/konkuk/chacall/global/common/dto/CursorPagingResponse.java``
totalSize: Long 구성요소 추가, of(..., Long totalSize) 오버로드 추가 및 기존 of(...)는 새 오버로드로 위임
서비스 로직 업데이트
\src/main/java/konkuk/chacall/domain/member/application/foodtruck/SavedFoodTruckService.java``
슬라이스 조회 후 SavedFoodTruck에서 직접 응답 생성, 저장소로부터 totalSize 조회, CursorPagingResponse.of 호출에 totalSize 전달 및 커서 키 매퍼를 SavedFoodTruckResponse::savedFoodTruckId로 변경

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>
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • 중점 검토 항목:
    • 커서 키 변경(SavedFoodTruckResponse::savedFoodTruckId)로 인한 페이징 일관성(기존 클라이언트/프론트 영향) 확인
    • SavedFoodTruckResponse.of 변경으로 인한 계층/의존성(도메인 → 프레젠테이션) 영향 검토
    • CursorPagingResponse 오버로드가 기존 호출부에 미치는 영향(널 처리, 직렬화) 확인
    • count 쿼리 성능 및 조건(FoodTruckViewedStatus 필터) 검증

Possibly related PRs

Suggested reviewers

  • ksg1227

Poem

🐰 커서 홀이 걷혔네, 조심스레 뛰며,
저장된 아이디 하나하나 챙겨오고,
전체 수를 세어 바구니에 넣고,
페이지는 친절히 마지막을 알리네.
🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed PR 제목 "[FIX] 저장 푸드트럭 조회시 페이징 관련 이슈 해결"은 변경사항의 핵심을 명확하게 반영합니다. 실제 코드 변경사항을 보면 커서 키(foodTruckId → savedFoodTruckId)의 불일치 문제 해결과 totalSize 필드 추가라는 두 가지 페이징 관련 수정이 포함되어 있으며, 제목이 이를 적절히 대표합니다. 제목은 간결하고 개발자가 스캔할 때 주요 변경사항을 이해할 수 있습니다.
Linked Issues Check ✅ Passed 연결된 이슈 #57의 요구사항은 페이징 커서 변수 불일치 해결 및 전체 데이터 크기(totalSize) 반환 두 가지입니다. 코드 변경사항이 이를 완전히 충족합니다: SavedFoodTruckResponse.java에서 savedFoodTruckId 필드를 추가하고 팩토리 메서드를 변경하여 커서 키 불일치 문제를 해결했으며, CursorPagingResponse.java에서 totalSize 필드와 오버로딩된 of 메서드를 추가하고 SavedFoodTruckService.java에서 이를 활용하여 전체 크기를 응답에 포함시킵니다. SavedFoodTruckRepository.java의 countByMemberAndFoodTruckViewedStatus 메서드도 totalSize 계산을 지원합니다.
Out of Scope Changes Check ✅ Passed 모든 코드 변경사항이 이슈 #57의 범위 내에 있습니다. SavedFoodTruckService.java의 페이징 로직 변경, SavedFoodTruckRepository.java의 카운트 메서드 추가, SavedFoodTruckResponse.java의 필드 및 메서드 변경, 그리고 CursorPagingResponse.java의 totalSize 추가는 모두 두 가지 핵심 목표(커서 키 불일치 해결 및 totalSize 추가)를 달성하기 위한 것입니다. 범위를 벗어난 변경사항이 발견되지 않습니다.
✨ 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 fix/#57-paging-issue

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dd9e12e and 1398016.

📒 Files selected for processing (1)
  • src/main/java/konkuk/chacall/domain/member/presentation/dto/response/SavedFoodTruckResponse.java (3 hunks)
🔇 Additional comments (3)
src/main/java/konkuk/chacall/domain/member/presentation/dto/response/SavedFoodTruckResponse.java (3)

3-3: 이전 리뷰 피드백이 정확히 반영되었습니다! 👍

Jackson의 @JsonIgnore를 올바르게 import하여 API 응답에서 savedFoodTruckId 필드가 제대로 제외됩니다. SavedFoodTruck import도 팩토리 메서드 변경에 필요한 적절한 추가입니다.

Also applies to: 7-7


25-29: 커서 페이징용 내부 필드가 적절하게 구현되었습니다.

savedFoodTruckId 필드에 @JsonIgnore@Schema(hidden = true) 어노테이션을 함께 사용하여 JSON 직렬화와 API 문서 모두에서 제외되도록 처리한 점이 좋습니다. 커서 기반 페이징에서 올바른 키(savedFoodTruckId)를 사용할 수 있게 되어 이슈 #57에서 보고된 페이징 문제가 해결됩니다.


31-43: 팩토리 메서드가 페이징 이슈 해결을 위해 올바르게 수정되었습니다.

메서드 시그니처를 SavedFoodTruck을 받도록 변경하여 savedFoodTruckId에 접근할 수 있게 된 점이 핵심입니다. 내부적으로 FoodTruck을 추출하여 기존 필드들을 채우고, 새로 추가된 savedFoodTruckId를 생성자에 전달하는 로직이 명확합니다.


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.

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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 98c16a2 and dd9e12e.

📒 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;
Copy link

@coderabbitai coderabbitai bot Nov 1, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

잘못된 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.

Copy link
Contributor

Choose a reason for hiding this comment

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

이부분 한 번만 확인부탁드립니다!

Copy link

Choose a reason for hiding this comment

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

🧩 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 응답에서 제외됩니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

흠 스웨거 상에서는 응답이 안보이는걸로 확인하긴했는데 그래도 jackson 사용으로 일관성을 맞추는게 좋아보이네요! 수정하겠습니다~

Copy link

Choose a reason for hiding this comment

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

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!

Copy link
Contributor

@ksg1227 ksg1227 left a comment

Choose a reason for hiding this comment

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

확인했습니다! 코래 코멘트 확인 한 번만 부탁드려요~

@buzz0331 buzz0331 merged commit ef6c144 into develop Nov 1, 2025
2 checks passed
@buzz0331 buzz0331 deleted the fix/#57-paging-issue branch November 1, 2025 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FIX] 저장 푸드트럭 조회시 페이징 관련 이슈 해결

2 participants