Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #211 from FinFellows/develop
Browse files Browse the repository at this point in the history
[FIX] financialProduct 북마크 조회 시 saving_term 12개월 인 것만 출력
  • Loading branch information
LEEJaeHyeok97 authored Jan 18, 2024
2 parents cdaaf0f + 101f8a0 commit d2fab22
Showing 1 changed file with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,33 @@ public static List<FinancialProductBookmarkRes> toDto(List<FinancialProductBookm
FinancialProduct financialProduct = bookmark.getFinancialProduct();
Long financialProductId = financialProduct.getId();

// financialProductId가 이미 포함되어 있으면 건너뛴다
// Skip if financialProductId is already included
if (!includedFinancialProductIds.contains(financialProductId)) {
String bankName = financialProduct.getBankName();
String bankLogoUrl = bankRepository.findByBankName(bankName) != null ? bankRepository.findByBankName(bankName).getBankLogoUrl() : null;

// 대표 옵션 선택 또는 모든 옵션 정보 집계
FinancialProductOption representativeOption = financialProduct.getFinancialProductOption().get(0); // 예시: 첫 번째 옵션 사용

results.add(FinancialProductBookmarkRes.builder()
.isLiked(Boolean.TRUE)
.financialProductId(financialProductId)
.financialProductType(financialProduct.getFinancialProductType())
.companyName(bankName)
.productName(financialProduct.getProductName())
.interestRate(representativeOption.getInterestRate())
.maximumPreferredInterestRate(representativeOption.getMaximumPreferredInterestRate())
.bankLogoUrl(bankLogoUrl)
.build());

// financialProductId를 포함된 목록에 추가한다
includedFinancialProductIds.add(financialProductId);
// Check if any of the FinancialProductOptions have a savingTerm of 12
boolean hasSavingTerm12 = financialProduct.getFinancialProductOption().stream()
.anyMatch(option -> option.getSavingsTerm() != null && option.getSavingsTerm().equals(12));

if (hasSavingTerm12) {
String bankName = financialProduct.getBankName();
String bankLogoUrl = bankRepository.findByBankName(bankName) != null ? bankRepository.findByBankName(bankName).getBankLogoUrl() : null;

// Use the first option as the representative option
FinancialProductOption representativeOption = financialProduct.getFinancialProductOption().get(0);

results.add(FinancialProductBookmarkRes.builder()
.isLiked(Boolean.TRUE)
.financialProductId(financialProductId)
.financialProductType(financialProduct.getFinancialProductType())
.companyName(bankName)
.productName(financialProduct.getProductName())
.interestRate(representativeOption.getInterestRate())
.maximumPreferredInterestRate(representativeOption.getMaximumPreferredInterestRate())
.bankLogoUrl(bankLogoUrl)
.build());

// Add the financialProductId to the included set
includedFinancialProductIds.add(financialProductId);
}
}
}

Expand Down

0 comments on commit d2fab22

Please sign in to comment.