diff --git a/src/main/java/co/orange/ddanzi/dto/home/HomeDetailResponseDto.java b/src/main/java/co/orange/ddanzi/dto/home/HomeDetailResponseDto.java index ed3cd350..4e399a6c 100644 --- a/src/main/java/co/orange/ddanzi/dto/home/HomeDetailResponseDto.java +++ b/src/main/java/co/orange/ddanzi/dto/home/HomeDetailResponseDto.java @@ -18,6 +18,7 @@ public class HomeDetailResponseDto { private Integer salePrice; private Integer stockCount; private String infoUrl; + private Boolean isInterested; private Integer interestCount; private List optionList; } diff --git a/src/main/java/co/orange/ddanzi/service/HomeService.java b/src/main/java/co/orange/ddanzi/service/HomeService.java index 86718d3e..174bfa0c 100644 --- a/src/main/java/co/orange/ddanzi/service/HomeService.java +++ b/src/main/java/co/orange/ddanzi/service/HomeService.java @@ -59,11 +59,20 @@ public ApiResponse getProductList(){ @Transactional public ApiResponse getProductDetail(String devicetoken, String productId){ + User user = authUtils.getUser(); + List productInfoList = new ArrayList<>(); + log.info("상품 조회 -> product_id: {}", productId); Product product = productRepository.findById(productId).orElse(null); if(product == null){ return ApiResponse.onFailure(Error.PRODUCT_NOT_FOUND, null); } + + Boolean isInterested = Boolean.FALSE; + if(user!=null) { + log.info("User is not null"); + isInterested = interestProductRepository.existsByIdUserAndIdProduct(user, product); + } log.info("해당 상품의 리프 카테고리 찾기"); if(product.getLeafCategory() == null){ ApiResponse.onFailure(Error.CATEGORY_NOT_FOUND, null); @@ -102,6 +111,7 @@ public ApiResponse getProductDetail(String devicetoken, String productId){ .infoUrl(product.getInfoUrl()) .stockCount(product.getStock()) .infoUrl(product.getInfoUrl()) + .isInterested(isInterested) .interestCount(interestCount) .optionList(optionList) .build();