Skip to content

Commit

Permalink
feat: add isInterested field
Browse files Browse the repository at this point in the history
  • Loading branch information
Kang1221 committed Aug 15, 2024
1 parent 446a1be commit 3a86fab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class HomeDetailResponseDto {
private Integer salePrice;
private Integer stockCount;
private String infoUrl;
private Boolean isInterested;
private Integer interestCount;
private List<OptionInfo> optionList;
}
10 changes: 10 additions & 0 deletions src/main/java/co/orange/ddanzi/service/HomeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,20 @@ public ApiResponse<?> getProductList(){

@Transactional
public ApiResponse<?> getProductDetail(String devicetoken, String productId){
User user = authUtils.getUser();
List<ProductInfo> 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);
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 3a86fab

Please sign in to comment.