From d0fc06a58ff3ba067cb002ba73bdb2c67290835f Mon Sep 17 00:00:00 2001 From: JSoi Date: Fri, 29 Jul 2022 18:46:00 +0900 Subject: [PATCH] =?UTF-8?q?#39=20[Update]=20=ED=8E=98=EC=9D=B4=EC=A7=95=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/dto/StoreCardResponseDto.java | 16 ---------------- .../store/dto/StorePagedResponseDto.java | 12 +++++++++--- .../baechelin/store/service/StoreService.java | 2 +- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/mpnp/baechelin/store/dto/StoreCardResponseDto.java b/src/main/java/com/mpnp/baechelin/store/dto/StoreCardResponseDto.java index 52c286f..2287026 100644 --- a/src/main/java/com/mpnp/baechelin/store/dto/StoreCardResponseDto.java +++ b/src/main/java/com/mpnp/baechelin/store/dto/StoreCardResponseDto.java @@ -37,22 +37,6 @@ public class StoreCardResponseDto { @Builder.Default private double pointAvg = 0.0; - public StoreCardResponseDto(Store store) { - this.storeId = store.getId(); - this.category = store.getCategory(); - this.name = store.getName(); - this.latitude = store.getLatitude(); - this.longitude = store.getLongitude(); - this.address = store.getAddress(); - this.elevator = store.getElevator(); - this.toilet = store.getToilet(); - this.parking = store.getParking(); - this.phoneNumber = store.getPhoneNumber(); - this.heightDifferent = store.getHeightDifferent(); - this.approach = store.getApproach(); - this.bookmarkCount = store.getBookMarkCount(); - } - public StoreCardResponseDto(Store store, String isBookMark) { this.storeId = store.getId(); this.category = store.getCategory(); diff --git a/src/main/java/com/mpnp/baechelin/store/dto/StorePagedResponseDto.java b/src/main/java/com/mpnp/baechelin/store/dto/StorePagedResponseDto.java index 1e89072..0bd39cd 100644 --- a/src/main/java/com/mpnp/baechelin/store/dto/StorePagedResponseDto.java +++ b/src/main/java/com/mpnp/baechelin/store/dto/StorePagedResponseDto.java @@ -1,9 +1,11 @@ package com.mpnp.baechelin.store.dto; +import com.mpnp.baechelin.store.domain.Store; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import org.springframework.data.domain.Page; import java.util.List; @@ -13,11 +15,15 @@ public class StorePagedResponseDto { private boolean hasNextPage; private long totalCount; + private long leftElement; + private int page; private List cards; - public StorePagedResponseDto(boolean hasNextPage, List cards, long totalCount) { - this.hasNextPage = hasNextPage; + public StorePagedResponseDto(Page resultStoreList, List cards) { + this.hasNextPage = resultStoreList.hasNext(); this.cards = cards; - this.totalCount = totalCount; + this.totalCount = resultStoreList.getTotalElements(); + this.page = resultStoreList.getNumber(); + this.leftElement = totalCount - (long) page * resultStoreList.getSize(); } } \ No newline at end of file diff --git a/src/main/java/com/mpnp/baechelin/store/service/StoreService.java b/src/main/java/com/mpnp/baechelin/store/service/StoreService.java index ef4ec0a..50f8772 100644 --- a/src/main/java/com/mpnp/baechelin/store/service/StoreService.java +++ b/src/main/java/com/mpnp/baechelin/store/service/StoreService.java @@ -124,7 +124,7 @@ private StorePagedResponseDto getStoreCardPagedResponseDto(User targetUser, Page boolean isBookmark = bookmarkRepository.existsByStoreIdAndUserId(store, targetUser); mappingResult.add(new StoreCardResponseDto(store, isBookmark ? "Y" : "N")); } - return new StorePagedResponseDto(resultStoreList.hasNext(), mappingResult, resultStoreList.getTotalElements()); + return new StorePagedResponseDto(resultStoreList, mappingResult); }