Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
@@ -1,8 +1,10 @@
package konkuk.chacall.domain.member.presentation.dto.response;

import com.fasterxml.jackson.annotation.JsonIgnore;
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 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);
}
}