Skip to content

Commit

Permalink
Merge pull request #58 from devSojoong/feature/#57-추천상품목록_관심상품등록값추가
Browse files Browse the repository at this point in the history
Feat: #57 - 추천 상품 목록 api 에 관심 상품 등록 값 추가
  • Loading branch information
devSojoong authored Feb 24, 2023
2 parents 876bb98 + e8f3f69 commit b6c56e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ public List<RecommendResponseDTO> recommendList(HttpServletRequest request) {
List<EntityFProduct> 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;
Expand Down

0 comments on commit b6c56e4

Please sign in to comment.