Skip to content

Commit

Permalink
#39 [Update] 페이징 정보 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
JSoi committed Jul 29, 2022
1 parent 2481cb8 commit d0fc06a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -13,11 +15,15 @@
public class StorePagedResponseDto {
private boolean hasNextPage;
private long totalCount;
private long leftElement;
private int page;
private List<StoreCardResponseDto> cards;

public StorePagedResponseDto(boolean hasNextPage, List<StoreCardResponseDto> cards, long totalCount) {
this.hasNextPage = hasNextPage;
public StorePagedResponseDto(Page<Store> resultStoreList, List<StoreCardResponseDto> 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down

0 comments on commit d0fc06a

Please sign in to comment.