From 85ec9f4423acbe9e6a329c1ba5514a6749159869 Mon Sep 17 00:00:00 2001 From: sung-silver Date: Tue, 15 Aug 2023 05:22:55 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[FIX]=20BakeryMapper=EB=A5=BC=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=98=EC=97=AC=20toBakeryDetailResponseDTO?= =?UTF-8?q?=EB=A5=BC=20=ED=86=B5=ED=95=9C=20=EB=A6=AC=ED=8C=A9=ED=86=A0?= =?UTF-8?q?=EB=A7=81=20=EA=B5=AC=ED=98=84=ED=95=B4=EB=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DTO/response/BakeryDetailResponseDTO.java | 2 +- .../org/gunbbang/service/BakeryService.java | 39 +++++-------------- .../gunbbang/util/mapper/BakeryMapper.java | 15 +++++-- 3 files changed, 22 insertions(+), 34 deletions(-) diff --git a/api/src/main/java/com/org/gunbbang/controller/DTO/response/BakeryDetailResponseDTO.java b/api/src/main/java/com/org/gunbbang/controller/DTO/response/BakeryDetailResponseDTO.java index 9da16bb6..89ed0bfb 100644 --- a/api/src/main/java/com/org/gunbbang/controller/DTO/response/BakeryDetailResponseDTO.java +++ b/api/src/main/java/com/org/gunbbang/controller/DTO/response/BakeryDetailResponseDTO.java @@ -19,7 +19,7 @@ public class BakeryDetailResponseDTO extends BaseBakeryResponseDTO { private String homepageUrl; private String instagramUrl; private String address; - private String openingTime; + private String openingHours; private String closedDay; private String phoneNumber; private List menuList; diff --git a/api/src/main/java/com/org/gunbbang/service/BakeryService.java b/api/src/main/java/com/org/gunbbang/service/BakeryService.java index 4e33da1b..cb3a1ad0 100644 --- a/api/src/main/java/com/org/gunbbang/service/BakeryService.java +++ b/api/src/main/java/com/org/gunbbang/service/BakeryService.java @@ -82,6 +82,14 @@ public BakeryDetailResponseDTO getBakeryDetail(Long memberId, Long bakeryId) { BreadTypeResponseDTO breadType = getBreadType(bakery); boolean isBookMarked = isBookMarked(memberId, bakeryId); List menuList = new ArrayList<>(); + String address = + bakery.getState() + + " " + + bakery.getCity() + + " " + + bakery.getTown() + + " " + + bakery.getAddressRest(); for (Menu menu : bakeryMenu) { menuList.add( @@ -92,35 +100,8 @@ public BakeryDetailResponseDTO getBakeryDetail(Long memberId, Long bakeryId) { .build()); } - return BakeryDetailResponseDTO.builder() - .bakeryId(bakery.getBakeryId()) - .bakeryName(bakery.getBakeryName()) - .bakeryPicture(bakery.getBakeryPicture()) - .isHACCP(bakery.getIsHACCP()) - .isVegan(bakery.getIsVegan()) - .isNonGMO(bakery.getIsNonGMO()) - .breadType(breadType) - .firstNearStation(bakery.getFirstNearStation()) - .secondNearStation(bakery.getSecondNearStation()) - .isBookMarked(isBookMarked) - .bookMarkCount(bakery.getBookMarkCount()) - .reviewCount(bakery.getReviewCount()) - .mapUrl(bakery.getMapUrl()) - .homepageUrl(bakery.getHomepageUrl()) - .instagramUrl(bakery.getInstagramUrl()) - .address( - bakery.getState() - + " " - + bakery.getCity() - + " " - + bakery.getTown() - + " " - + bakery.getAddressRest()) - .openingTime(bakery.getOpeningHours()) - .closedDay(bakery.getClosedDay()) - .phoneNumber(bakery.getPhoneNumber()) - .menuList(menuList) - .build(); + return BakeryMapper.INSTANCE.toBakeryDetailResponseDTO( + bakery, address, breadType, isBookMarked, menuList); } public List getBestBakeries(Long memberId) { diff --git a/api/src/main/java/com/org/gunbbang/util/mapper/BakeryMapper.java b/api/src/main/java/com/org/gunbbang/util/mapper/BakeryMapper.java index ab351df6..6100a421 100644 --- a/api/src/main/java/com/org/gunbbang/util/mapper/BakeryMapper.java +++ b/api/src/main/java/com/org/gunbbang/util/mapper/BakeryMapper.java @@ -1,9 +1,6 @@ package com.org.gunbbang.util.mapper; -import com.org.gunbbang.controller.DTO.response.BakeryListResponseDTO; -import com.org.gunbbang.controller.DTO.response.BakerySearchResponseDTO; -import com.org.gunbbang.controller.DTO.response.BestBakeryListResponseDTO; -import com.org.gunbbang.controller.DTO.response.BreadTypeResponseDTO; +import com.org.gunbbang.controller.DTO.response.*; import com.org.gunbbang.entity.Bakery; import java.util.List; import org.mapstruct.Mapper; @@ -24,4 +21,14 @@ BakerySearchResponseDTO toBakerySearchResponseDTO( int resultCount, List bakeryList); List toBestBakeryListResponseDTO(List bakeries); + + @Mapping(source = "bakery.isHACCP", target = "isHACCP") + @Mapping(source = "bakery.isVegan", target = "isVegan") + @Mapping(source = "bakery.isNonGMO", target = "isNonGMO") + BakeryDetailResponseDTO toBakeryDetailResponseDTO( + Bakery bakery, + String address, + BreadTypeResponseDTO breadType, + boolean isBookMarked, + List menuList); } From 7aba394294b63ef925771b9327f563afc53b4ae3 Mon Sep 17 00:00:00 2001 From: sung-silver Date: Tue, 15 Aug 2023 05:28:46 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[FIX]=20MenuMapper=EB=A5=BC=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=ED=95=98=EA=B3=A0=20BakeryService=20=EB=82=B4=20getBa?= =?UTF-8?q?keryDetail=20=EB=A1=9C=EC=A7=81=EC=97=90=20=EC=A0=81=EC=9A=A9?= =?UTF-8?q?=ED=95=B4=EB=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/org/gunbbang/service/BakeryService.java | 12 ++---------- .../com/org/gunbbang/util/mapper/MenuMapper.java | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 api/src/main/java/com/org/gunbbang/util/mapper/MenuMapper.java diff --git a/api/src/main/java/com/org/gunbbang/service/BakeryService.java b/api/src/main/java/com/org/gunbbang/service/BakeryService.java index cb3a1ad0..14b9e0d2 100644 --- a/api/src/main/java/com/org/gunbbang/service/BakeryService.java +++ b/api/src/main/java/com/org/gunbbang/service/BakeryService.java @@ -10,6 +10,7 @@ import com.org.gunbbang.service.specification.BakerySpecifications; import com.org.gunbbang.util.mapper.BakeryMapper; import com.org.gunbbang.util.mapper.BreadTypeMapper; +import com.org.gunbbang.util.mapper.MenuMapper; import java.util.*; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; @@ -81,7 +82,7 @@ public BakeryDetailResponseDTO getBakeryDetail(Long memberId, Long bakeryId) { List bakeryMenu = menuRepository.findAllByBakery(bakery); BreadTypeResponseDTO breadType = getBreadType(bakery); boolean isBookMarked = isBookMarked(memberId, bakeryId); - List menuList = new ArrayList<>(); + List menuList = MenuMapper.INSTANCE.toMenuResponseDTOList(bakeryMenu); String address = bakery.getState() + " " @@ -91,15 +92,6 @@ public BakeryDetailResponseDTO getBakeryDetail(Long memberId, Long bakeryId) { + " " + bakery.getAddressRest(); - for (Menu menu : bakeryMenu) { - menuList.add( - MenuResponseDTO.builder() - .menuId(menu.getMenuId()) - .menuName(menu.getMenuName()) - .menuPrice(menu.getMenuPrice()) - .build()); - } - return BakeryMapper.INSTANCE.toBakeryDetailResponseDTO( bakery, address, breadType, isBookMarked, menuList); } diff --git a/api/src/main/java/com/org/gunbbang/util/mapper/MenuMapper.java b/api/src/main/java/com/org/gunbbang/util/mapper/MenuMapper.java new file mode 100644 index 00000000..19d3ce52 --- /dev/null +++ b/api/src/main/java/com/org/gunbbang/util/mapper/MenuMapper.java @@ -0,0 +1,15 @@ +package com.org.gunbbang.util.mapper; + +import com.org.gunbbang.controller.DTO.response.MenuResponseDTO; +import com.org.gunbbang.entity.Menu; +import java.util.List; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; +import org.mapstruct.factory.Mappers; + +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.ERROR) +public interface MenuMapper { + MenuMapper INSTANCE = Mappers.getMapper(MenuMapper.class); + + List toMenuResponseDTOList(List menuList); +} From 2f2a4ef501d55cb6aa9d18362c9b84c14a6092c3 Mon Sep 17 00:00:00 2001 From: sung-silver Date: Tue, 15 Aug 2023 05:30:30 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[FIX]=20=EB=A7=A4=EA=B0=9C=EB=B3=80?= =?UTF-8?q?=EC=88=98=20=EC=A0=84=EB=8B=AC=EC=9D=84=20=EC=9C=84=ED=95=9C=20?= =?UTF-8?q?=EB=8B=A8=EC=88=9C=20=EB=B3=80=EC=88=98=20=EC=84=A0=EC=96=B8?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=83=9D=EA=B0=81=EB=90=98=EB=8A=94=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=83=9D=EB=9E=B5=ED=95=B4=EB=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/src/main/java/com/org/gunbbang/service/BakeryService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/com/org/gunbbang/service/BakeryService.java b/api/src/main/java/com/org/gunbbang/service/BakeryService.java index 14b9e0d2..dfba314c 100644 --- a/api/src/main/java/com/org/gunbbang/service/BakeryService.java +++ b/api/src/main/java/com/org/gunbbang/service/BakeryService.java @@ -79,10 +79,10 @@ public BakeryDetailResponseDTO getBakeryDetail(Long memberId, Long bakeryId) { bakeryRepository .findById(bakeryId) .orElseThrow(() -> new NotFoundException(ErrorType.NOT_FOUND_BAKERY_EXCEPTION)); - List bakeryMenu = menuRepository.findAllByBakery(bakery); BreadTypeResponseDTO breadType = getBreadType(bakery); boolean isBookMarked = isBookMarked(memberId, bakeryId); - List menuList = MenuMapper.INSTANCE.toMenuResponseDTOList(bakeryMenu); + List menuList = + MenuMapper.INSTANCE.toMenuResponseDTOList(menuRepository.findAllByBakery(bakery)); String address = bakery.getState() + " " From a3f906d352c1fe2030cb748c0a16fd1b4a019c2f Mon Sep 17 00:00:00 2001 From: sung-silver Date: Tue, 15 Aug 2023 06:03:20 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[FIX]=20=EC=BD=94=EB=93=9C=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/gunbbang/service/BakeryService.java | 21 ++++++++++--------- .../com/org/gunbbang/util/ConstantVO.java | 5 +++++ 2 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 api/src/main/java/com/org/gunbbang/util/ConstantVO.java diff --git a/api/src/main/java/com/org/gunbbang/service/BakeryService.java b/api/src/main/java/com/org/gunbbang/service/BakeryService.java index dfba314c..a8f5a723 100644 --- a/api/src/main/java/com/org/gunbbang/service/BakeryService.java +++ b/api/src/main/java/com/org/gunbbang/service/BakeryService.java @@ -1,5 +1,7 @@ package com.org.gunbbang.service; +import static com.org.gunbbang.util.ConstantVO.BLANK_SPACE; + import com.org.gunbbang.CategoryType; import com.org.gunbbang.NotFoundException; import com.org.gunbbang.controller.DTO.response.*; @@ -79,23 +81,22 @@ public BakeryDetailResponseDTO getBakeryDetail(Long memberId, Long bakeryId) { bakeryRepository .findById(bakeryId) .orElseThrow(() -> new NotFoundException(ErrorType.NOT_FOUND_BAKERY_EXCEPTION)); - BreadTypeResponseDTO breadType = getBreadType(bakery); + BreadTypeResponseDTO breadType = + BreadTypeMapper.INSTANCE.toBreadTypeResponseDTO(bakery.getBreadType()); boolean isBookMarked = isBookMarked(memberId, bakeryId); - List menuList = - MenuMapper.INSTANCE.toMenuResponseDTOList(menuRepository.findAllByBakery(bakery)); + List bakeryMenuList = menuRepository.findAllByBakery(bakery); + List menuList = MenuMapper.INSTANCE.toMenuResponseDTOList(bakeryMenuList); String address = - bakery.getState() - + " " - + bakery.getCity() - + " " - + bakery.getTown() - + " " - + bakery.getAddressRest(); + getAddress(bakery.getState(), bakery.getCity(), bakery.getTown(), bakery.getAddressRest()); return BakeryMapper.INSTANCE.toBakeryDetailResponseDTO( bakery, address, breadType, isBookMarked, menuList); } + String getAddress(String state, String city, String town, String addressRest) { + return state + BLANK_SPACE + city + BLANK_SPACE + town + BLANK_SPACE + addressRest; + } + public List getBestBakeries(Long memberId) { List alreadyFoundBakeryIds = new ArrayList<>(); alreadyFoundBakeryIds.add(-1L); diff --git a/api/src/main/java/com/org/gunbbang/util/ConstantVO.java b/api/src/main/java/com/org/gunbbang/util/ConstantVO.java new file mode 100644 index 00000000..1eda8ebc --- /dev/null +++ b/api/src/main/java/com/org/gunbbang/util/ConstantVO.java @@ -0,0 +1,5 @@ +package com.org.gunbbang.util; + +public class ConstantVO { + public static final String BLANK_SPACE = " "; +}