Skip to content

Commit

Permalink
[FIX] 건빵집 상세보기 api를 제외한 다른 api에 isBookMarked 필드를 제외하라
Browse files Browse the repository at this point in the history
  • Loading branch information
seunghaLim committed Aug 12, 2023
1 parent db9ff5e commit fd72077
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,5 @@
public class BakeryListResponseDTO extends BaseBakeryResponseDTO {
private long reviewCount;
private BreadTypeResponseDTO breadType;
private boolean isBookMarked;
private long bookMarkCount;

public boolean getIsBookMarked() {
return isBookMarked;
}
}
26 changes: 8 additions & 18 deletions api/src/main/java/com/org/gunbbang/service/BakeryService.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public List<BakeryListResponseDTO> getBakeryList(
List<Category> categoryList = getCategoryList(isHard, isDessert, isBrunch);
List<BakeryListResponseDTO> responseDtoList = new ArrayList<>();
BreadTypeResponseDTO breadType;
boolean isBookMarked;
List<Bakery> bakeryList;

if (categoryList.isEmpty()) {
Expand All @@ -47,9 +46,7 @@ public List<BakeryListResponseDTO> getBakeryList(
bakeryList = bakeryRepository.findAll(sortOption);
for (Bakery bakery : bakeryList) {
breadType = getBreadType(bakery);
isBookMarked = isBookMarked(memberId, bakery.getBakeryId());
BakeryListResponseDTO bakeryListResponseDto =
getBakeryResponseDTO(bakery, isBookMarked, breadType);
BakeryListResponseDTO bakeryListResponseDto = getBakeryResponseDTO(bakery, breadType);
responseDtoList.add(bakeryListResponseDto);
}
return responseDtoList;
Expand All @@ -59,9 +56,7 @@ public List<BakeryListResponseDTO> getBakeryList(
bakeryList = bakeryRepository.findBakeriesByCategoryAndReview(categoryList);
for (Bakery bakery : bakeryList) {
breadType = getBreadType(bakery);
isBookMarked = isBookMarked(memberId, bakery.getBakeryId());
BakeryListResponseDTO bakeryListResponseDto =
getBakeryResponseDTO(bakery, isBookMarked, breadType);
BakeryListResponseDTO bakeryListResponseDto = getBakeryResponseDTO(bakery, breadType);
responseDtoList.add(bakeryListResponseDto);
}
return responseDtoList;
Expand All @@ -70,9 +65,7 @@ public List<BakeryListResponseDTO> getBakeryList(
bakeryList = bakeryRepository.findBakeriesByCategory(categoryList);
for (Bakery bakery : bakeryList) {
breadType = getBreadType(bakery);
isBookMarked = isBookMarked(memberId, bakery.getBakeryId());
BakeryListResponseDTO bakeryListResponseDto =
getBakeryResponseDTO(bakery, isBookMarked, breadType);
BakeryListResponseDTO bakeryListResponseDto = getBakeryResponseDTO(bakery, breadType);
responseDtoList.add(bakeryListResponseDto);
}
return responseDtoList;
Expand Down Expand Up @@ -197,22 +190,20 @@ public BakerySearchResponseDTO getBakeriesByName(String bakeryName, Long memberI

List<Bakery> foundBakeries = bakeryRepository.findBakeryByBakeryName(bakeryName);
List<BakeryListResponseDTO> bakeryListResponseDTOs =
getBakeryListResponseDTOList(memberId, foundBakeries);
getBakeryListResponseDTOList(foundBakeries);

return BakeryMapper.INSTANCE.toBakerySearchResponseDTO(
bakeryListResponseDTOs.size(), bakeryListResponseDTOs);
}

private List<BakeryListResponseDTO> getBakeryListResponseDTOList(
Long memberId, List<Bakery> foundBakeries) {
private List<BakeryListResponseDTO> getBakeryListResponseDTOList(List<Bakery> foundBakeries) {
List<BakeryListResponseDTO> bakeryListResponseDTOs = new ArrayList<>();

for (Bakery foundBakery : foundBakeries) {
boolean isBookMarked = isBookMarked(memberId, foundBakery.getBakeryId());
BreadTypeResponseDTO breadType =
BreadTypeMapper.INSTANCE.toBreadTypeResponseDTO(foundBakery.getBreadType());
BakeryListResponseDTO bakeryListResponseDTO =
BakeryMapper.INSTANCE.toBakeryListResponseDTO(foundBakery, isBookMarked, breadType);
BakeryMapper.INSTANCE.toBakeryListResponseDTO(foundBakery, breadType);
bakeryListResponseDTOs.add(bakeryListResponseDTO);
}

Expand Down Expand Up @@ -243,7 +234,7 @@ public BakerySearchResponseDTOV2 getBakeriesByNameV2(String bakeryName, Long mem

public List<BakeryListResponseDTO> getBookMarkedBakeries(Long memberId) {
List<Bakery> bookMarkedBakeries = bakeryRepository.findBookMarkedBakeries(memberId);
return getBakeryListResponseDTOList(memberId, bookMarkedBakeries);
return getBakeryListResponseDTOList(bookMarkedBakeries);
}

// TODO: 공통적으로 사용되는 메서드라 다른 곳으로는 못뺄지
Expand All @@ -266,7 +257,7 @@ private BreadTypeResponseDTO getBreadType(Bakery bakery) {
}

private BakeryListResponseDTO getBakeryResponseDTO(
Bakery bakery, boolean isBookMarked, BreadTypeResponseDTO breadType) {
Bakery bakery, BreadTypeResponseDTO breadType) {
return BakeryListResponseDTO.builder()
.bakeryId(bakery.getBakeryId())
.bakeryName(bakery.getBakeryName())
Expand All @@ -276,7 +267,6 @@ private BakeryListResponseDTO getBakeryResponseDTO(
.isNonGMO(bakery.getIsNonGMO())
.firstNearStation(bakery.getFirstNearStation())
.secondNearStation(bakery.getSecondNearStation())
.isBookMarked(isBookMarked)
.bookMarkCount(bakery.getBookMarkCount())
.reviewCount(bakery.getReviewCount())
.breadType(breadType)
Expand Down
7 changes: 0 additions & 7 deletions api/src/main/java/com/org/gunbbang/service/ReviewService.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,6 @@ private List<BestReviewListResponseDTO> getBestReviewsListResponseDTO(
return responseDtoList;
}

private boolean isBookMarked(Long memberId, Long bakeryId) {
if (bookMarkRepository.findByMemberIdAndBakeryId(memberId, bakeryId).isPresent()) {
return true;
}
return false;
}

private String[] getMaxRecommendKeywords(BestReviewDTO bestReview) {

Map<String, Long> recommendKeywordsMap = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ public interface BakeryMapper {
@Mapping(source = "bakery.isHACCP", target = "isHACCP")
@Mapping(source = "bakery.isVegan", target = "isVegan")
@Mapping(source = "bakery.isNonGMO", target = "isNonGMO")
BakeryListResponseDTO toBakeryListResponseDTO(
Bakery bakery, boolean isBookMarked, BreadTypeResponseDTO breadType);
BakeryListResponseDTO toBakeryListResponseDTO(Bakery bakery, BreadTypeResponseDTO breadType);

BakerySearchResponseDTO toBakerySearchResponseDTO(
int resultCount, List<BakeryListResponseDTO> bakeryList);
Expand Down

0 comments on commit fd72077

Please sign in to comment.