Skip to content

Commit

Permalink
feat: store 조회 구현 - #23
Browse files Browse the repository at this point in the history
  • Loading branch information
sjk4618 committed Jan 15, 2025
1 parent 7f68238 commit 95adb2c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public StoreInfoDto(Long storeId,
Station station,
String address,
boolean isLiked,
int nextCursor) {
int storeLikesCount) {
this.storeId = storeId;
this.name = name;
this.station = station;
this.address = address;
this.isLiked = isLiked;
this.storeLikesCount = nextCursor;
this.storeLikesCount = storeLikesCount;
}
}
33 changes: 29 additions & 4 deletions cakey-domain/src/main/java/com/cakey/store/facade/StoreFacade.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.cakey.store.facade;

import com.cakey.OrderBy;
import com.cakey.store.domain.Station;
import com.cakey.store.dto.StoreCoordianteDto;
import com.cakey.store.dto.StoreInfoDto;
Expand All @@ -12,12 +11,14 @@
@Component
@RequiredArgsConstructor
public class StoreFacade {

private final StoreRetriever storeRetriever;

public List<StoreCoordianteDto> findCoordinatesByStation(final Station station) {
return storeRetriever.findCoordinateByStation(station);
}

//스토어 조회(인기순)
public List<StoreInfoDto> findStoreInfoByStationAndLikes(final Long userId,
final Station station,
final int likesCursor,
Expand All @@ -26,21 +27,45 @@ public List<StoreInfoDto> findStoreInfoByStationAndLikes(final Long userId,
return storeRetriever.findStoreInfoByStationAndLikes(userId, station, likesCursor, lastStoreId, size);
}

//스토어 조회(최신순)
public List<StoreInfoDto> findStoreInfoByStationAndLatest(final Long userId,
final Station station,
final Long storeCursorId,
final int size) {

return storeRetriever.findStoreInfoByStationAndLatest(userId, station, storeCursorId, size);
}
//찜한 스토어(최신순)
public List<StoreInfoDto> findLatestStoresLikedByUser(final Long userId,
final Long storeIdCursor,
final int size) {
return storeRetriever.findStoresLikedByUser(userId, storeIdCursor, size);
}

// 조회한 store들의 ID 추출
public List<Long> getStoreIds(final List<StoreInfoDto> storeInfoDtos) {
return storeInfoDtos.stream()
.map(StoreInfoDto::getStoreId)
.toList();
}

//스토어 개수 조회
public int getStoreCountByStation(final Station station) {
return (station == Station.ALL)
? countAllStores()
: countStoresByStation(station);
}

public int countAllStores() {
private int countAllStores() {
return storeRetriever.countAllStores();
}

public int countStoresByStation(final Station station) {
private int countStoresByStation(final Station station) {
return storeRetriever.countStoresByStation(station);
}

//마지막 스토어아이디 계싼
public Long calculateLastStoreId(final List<StoreInfoDto> storeInfoDtos) {
return storeInfoDtos.isEmpty() ? null : storeInfoDtos.get(storeInfoDtos.size() - 1).getStoreId();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public List<StoreCoordianteDto> findCoordinateByStation(final Station station) {
return storeRepository.findStoreCoordinatesByStation(station);
}

//스토어 조회(인기순)
public List<StoreInfoDto> findStoreInfoByStationAndLikes(final Long userId,
final Station station,
final int likesCursor,
Expand All @@ -26,13 +27,21 @@ public List<StoreInfoDto> findStoreInfoByStationAndLikes(final Long userId,
return storeRepository.findStoreInfoByStationAndLikes(userId, station, likesCursor, lastStoreId, size);
}

//스토어 조회(최신순)
public List<StoreInfoDto> findStoreInfoByStationAndLatest(final Long userId,
final Station station,
final Long storeIdCursor,
final int size) {
return storeRepository.findStoreInfoByStationAndLatest(userId, station, storeIdCursor, size);
}

//찜한 스토어 조회(최신순)
public List<StoreInfoDto> findStoresLikedByUser(final long userId,
final Long storeIdCursor,
final int size) {
return storeRepository.findStoresLikedByUser(userId, storeIdCursor, size);
}

public int countAllStores() {
return storeRepository.countAllStores();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ List<StoreInfoDto> findStoreInfoByStationAndLatest(final Long userId,
final Long storeIdCursor,
final int size);

List<StoreInfoDto> findStoresLikedByUser(final long userId,
final Long storeIdCursor,
final int size);
}

0 comments on commit 95adb2c

Please sign in to comment.