diff --git a/src/main/java/com/example/creditmarket/dto/response/RecommendResponseDTO.java b/src/main/java/com/example/creditmarket/dto/response/RecommendResponseDTO.java index 38aa21e..6962101 100644 --- a/src/main/java/com/example/creditmarket/dto/response/RecommendResponseDTO.java +++ b/src/main/java/com/example/creditmarket/dto/response/RecommendResponseDTO.java @@ -25,6 +25,8 @@ public class RecommendResponseDTO { private double avgInterest; + private boolean favorite; + public RecommendResponseDTO(EntityFProduct product, EntityOption option){ this.productId = product.getFproduct_id(); this.companyName = product.getFproduct_company_name(); @@ -33,4 +35,14 @@ public RecommendResponseDTO(EntityFProduct product, EntityOption option){ this.optionsInterestType = option.getOptions_interest_type(); this.avgInterest = option.getOptions_crdt_grad_avg(); } + + public RecommendResponseDTO(EntityFProduct product, EntityOption option, boolean favorite){ + this.productId = product.getFproduct_id(); + this.companyName = product.getFproduct_company_name(); + this.productName = product.getFproduct_name(); + this.productTypeName = product.getFproduct_credit_product_type_name(); + this.optionsInterestType = option.getOptions_interest_type(); + this.avgInterest = option.getOptions_crdt_grad_avg(); + this.favorite = favorite; + } } diff --git a/src/main/java/com/example/creditmarket/service/Impl/ProductServiceImpl.java b/src/main/java/com/example/creditmarket/service/Impl/ProductServiceImpl.java index d139471..1cfcedb 100644 --- a/src/main/java/com/example/creditmarket/service/Impl/ProductServiceImpl.java +++ b/src/main/java/com/example/creditmarket/service/Impl/ProductServiceImpl.java @@ -87,8 +87,9 @@ public List recommendList(HttpServletRequest request) { List products = productRepository.findProductsByUserPref(user.getUserPrefCreditProductTypeName()); for (EntityFProduct pr : products) { EntityOption op = optionRepository.findOptionByProductIdAndType(pr.getFproduct_id(), user.getUserPrefInterestType()); + boolean isFavorite = favoriteRepository.existsByUserAndFproduct(user, pr); if (op != null) { - list.add(new RecommendResponseDTO(pr, op)); + list.add(new RecommendResponseDTO(pr, op, isFavorite)); } } return list;