Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ public CursorPagingResponse<SavedFoodTruckResponse> getSavedFoodTrucks(CursorPag

// 응답 DTO로 변환
List<SavedFoodTruckResponse> responses = savedFoodTrucks.stream()
.map(SavedFoodTruck::getFoodTruck)
.map(SavedFoodTruckResponse::of)
.toList();

return CursorPagingResponse.of(responses, SavedFoodTruckResponse::foodTruckId, savedFoodTruckSlice.hasNext());
// 전체 저장 푸드트럭 갯수 조회
long totalSize = savedFoodTruckRepository.countByMemberAndFoodTruckViewedStatus(member, FoodTruckViewedStatus.ON);

return CursorPagingResponse.of(responses, SavedFoodTruckResponse::savedFoodTruckId, savedFoodTruckSlice.hasNext(), totalSize);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,10 @@ select exists (
""")
boolean existsByMemberIdAndFoodTruckId(@Param("userId") Long userId,
@Param("foodTruckId") Long foodTruckId);

@Query("SELECT COUNT(sft) FROM SavedFoodTruck sft " +
"WHERE sft.member = :member " +
"AND sft.foodTruck.foodTruckViewedStatus = :status")
long countByMemberAndFoodTruckViewedStatus(@Param("member") User member,
@Param("status") FoodTruckViewedStatus status);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import io.swagger.v3.oas.annotations.media.Schema;
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!


import java.util.List;

Expand All @@ -20,9 +22,14 @@ public record SavedFoodTruckResponse(
@Schema(description = "푸드트럭 평균 평점", example = "4.5")
Double averageRating,
@Schema(description = "푸드트럭 평점 수", example = "100")
Integer ratingCount
Integer ratingCount,

@JsonIgnore
@Schema(hidden = true, description = "커서 계산용 내부 필드 (응답에 미포함)")
Long savedFoodTruckId
) {
public static SavedFoodTruckResponse of(FoodTruck foodTruck) {
public static SavedFoodTruckResponse of(SavedFoodTruck savedFoodTruck) {
FoodTruck foodTruck = savedFoodTruck.getFoodTruck();
FoodTruckInfo foodTruckInfo = foodTruck.getFoodTruckInfo();
return new SavedFoodTruckResponse(
foodTruck.getFoodTruckId(),
Expand All @@ -31,7 +38,8 @@ public static SavedFoodTruckResponse of(FoodTruck foodTruck) {
foodTruckInfo.getDescription(),
foodTruckInfo.getMenuCategoryList().getMenuCategoryLabelList(),
foodTruck.getRatingInfo().getAverageRating(),
foodTruck.getRatingInfo().getRatingCount()
foodTruck.getRatingInfo().getRatingCount(),
savedFoodTruck.getSavedFoodTruckId()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,24 @@
public record CursorPagingResponse<T>(
List<T> content,
Long lastCursor,
boolean hasNext
boolean hasNext,
Long totalSize
) {
public static <T> CursorPagingResponse<T> of(
List<T> content,
CursorExtractor<T> extractor,
boolean hasNext
) {
return of(content, extractor, hasNext, null);
}

public static <T> CursorPagingResponse<T> of(
List<T> content,
CursorExtractor<T> extractor,
boolean hasNext,
Long totalSize
) {
Long lastCursor = (content == null || content.isEmpty()) ? null : extractor.extractCursor(content.get(content.size() - 1));
return new CursorPagingResponse<>(content, lastCursor, hasNext);
return new CursorPagingResponse<>(content, lastCursor, hasNext, totalSize);
}
}