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 #202 from FinFellows/develop
Browse files Browse the repository at this point in the history
[FIX]: 금융, 뭐하지 응답에 이미지 추가
  • Loading branch information
LEEJaeHyeok97 authored Jan 17, 2024
2 parents ee597f6 + 8bd241f commit 08448f6
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.finfellows.domain.bookmark.dto.FinancialProductBookmarkRes;
import com.finfellows.domain.product.domain.CMA;
import com.finfellows.domain.product.domain.FinancialProduct;
import com.finfellows.domain.product.domain.repository.BankRepository;
import com.finfellows.domain.product.domain.repository.CmaRepository;
import com.finfellows.domain.product.domain.repository.FinancialProductRepository;
import com.finfellows.domain.user.domain.User;
Expand Down Expand Up @@ -36,6 +37,7 @@ public class FinancialProductBookmarkServiceImpl implements BookmarkService{
private final FinancialProductRepository financialProductRepository;
private final CmaRepository cmaRepository;
private final CmaBookmarkRepository cmaBookmarkRepository;
private final BankRepository bankRepository;


@Transactional
Expand Down Expand Up @@ -96,8 +98,8 @@ public ResponseCustom<CmaFinancialProductBookmarkRes> findBookmarks(UserPrincipa
List<CmaBookmark> cmaBookmarks = cmaBookmarkRepository.findAllByUser(user);


List<FinancialProductBookmarkRes> financialProductBookmarkResList = FinancialProductBookmarkRes.toDto(bookmarks);
List<CmaBookmarkRes> cmaBookmarkResList = CmaBookmarkRes.toDto(cmaBookmarks);
List<FinancialProductBookmarkRes> financialProductBookmarkResList = FinancialProductBookmarkRes.toDto(bookmarks, bankRepository);
List<CmaBookmarkRes> cmaBookmarkResList = CmaBookmarkRes.toDto(cmaBookmarks, bankRepository);

CmaFinancialProductBookmarkRes cmaFinancialProductBookmarkRes = new CmaFinancialProductBookmarkRes(financialProductBookmarkResList, cmaBookmarkResList);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package com.finfellows.domain.bookmark.dto;

import com.finfellows.domain.bookmark.domain.CmaBookmark;
import com.finfellows.domain.product.domain.Bank;
import com.finfellows.domain.product.domain.repository.BankRepository;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.stream.Collectors;
Expand All @@ -16,34 +21,45 @@ public class CmaBookmarkRes {
private String cmaType;
private String maturityInterestRate;
private String specialCondition;
private String bankLogoUrl;




@Builder
public CmaBookmarkRes(Boolean isLiked, Long cmaId, String companyName, String productName, String cmaType, String maturityInterestRate, String specialCondition) {
public CmaBookmarkRes(Boolean isLiked, Long cmaId, String companyName, String productName, String cmaType, String maturityInterestRate, String specialCondition, String bankLogoUrl) {
this.isLiked = isLiked;
this.cmaId = cmaId;
this.companyName = companyName;
this.productName = productName;
this.cmaType = cmaType;
this.maturityInterestRate = maturityInterestRate;
this.specialCondition = specialCondition;
this.bankLogoUrl = bankLogoUrl;
}





public static List<CmaBookmarkRes> toDto(List<CmaBookmark> cmaBookmarks) {
public static List<CmaBookmarkRes> toDto(List<CmaBookmark> cmaBookmarks, BankRepository bankRepository) {

return cmaBookmarks.stream()
.map(bookmark -> CmaBookmarkRes.builder()
.isLiked(Boolean.TRUE)
.cmaId(bookmark.getCma().getId())
.cmaType(bookmark.getCma().getCmaType())
.productName(bookmark.getCma().getProductName())
.companyName(bookmark.getCma().getBankName())
.maturityInterestRate(bookmark.getCma().getMaturityInterestRate())
.specialCondition(bookmark.getCma().getSpecialCondition())
.build())
.map(bookmark -> {
Bank bank = bankRepository.findByBankName(bookmark.getCma().getBankName());
String bankLogoUrl = bank != null ? bank.getBankLogoUrl() : null;

return CmaBookmarkRes.builder()
.isLiked(Boolean.TRUE)
.cmaId(bookmark.getCma().getId())
.cmaType(bookmark.getCma().getCmaType())
.productName(bookmark.getCma().getProductName())
.companyName(bookmark.getCma().getBankName())
.maturityInterestRate(bookmark.getCma().getMaturityInterestRate())
.specialCondition(bookmark.getCma().getSpecialCondition())
.bankLogoUrl(bankLogoUrl)
.build();
})
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.finfellows.domain.product.domain.FinancialProduct;
import com.finfellows.domain.product.domain.FinancialProductOption;
import com.finfellows.domain.product.domain.FinancialProductType;
import com.finfellows.domain.product.domain.repository.BankRepository;
import lombok.Builder;
import lombok.Data;

Expand All @@ -21,40 +22,46 @@ public class FinancialProductBookmarkRes {
private String productName;
private String interestRate;
private String maximumPreferredInterestRate;
private String bankLogoUrl;



@Builder
public FinancialProductBookmarkRes(Boolean isLiked, Long financialProductId, FinancialProductType financialProductType, String companyName, String productName, String interestRate, String maximumPreferredInterestRate) {
public FinancialProductBookmarkRes(Boolean isLiked, Long financialProductId, FinancialProductType financialProductType, String companyName, String productName, String interestRate, String maximumPreferredInterestRate, String bankLogoUrl) {
this.isLiked = isLiked;
this.financialProductId = financialProductId;
this.financialProductType = financialProductType;
this.companyName = companyName;
this.productName = productName;
this.interestRate = interestRate;
this.maximumPreferredInterestRate = maximumPreferredInterestRate;
this.bankLogoUrl = bankLogoUrl;
}





public static List<FinancialProductBookmarkRes> toDto(List<FinancialProductBookmark> bookmarks) {
public static List<FinancialProductBookmarkRes> toDto(List<FinancialProductBookmark> bookmarks, BankRepository bankRepository) {
List<FinancialProductBookmarkRes> results = new ArrayList<>();

for (FinancialProductBookmark bookmark : bookmarks) {
FinancialProduct financialProduct = bookmark.getFinancialProduct();

for (FinancialProductOption financialProductOption : financialProduct.getFinancialProductOption()) {
Boolean isLiked = Boolean.TRUE;
Long financialProductId = financialProduct.getId();
FinancialProductType financialProductType = financialProduct.getFinancialProductType();
String companyName = financialProduct.getBankName();
String productName = financialProduct.getProductName();
String interestRate = financialProductOption.getInterestRate();
String maximumPreferredInterestRate = financialProductOption.getMaximumPreferredInterestRate();

results.add(new FinancialProductBookmarkRes(isLiked ,financialProductId ,financialProductType, companyName, productName, interestRate, maximumPreferredInterestRate));
String bankName = financialProduct.getBankName();
String bankLogoUrl = bankRepository.findByBankName(bankName) != null ? bankRepository.findByBankName(bankName).getBankLogoUrl() : null;

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

}
}
Expand Down

0 comments on commit 08448f6

Please sign in to comment.