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 #82 from FinFellows/develop
Browse files Browse the repository at this point in the history
[FEAT] financialProduct 북마크 조회 방식 수정
  • Loading branch information
LEEJaeHyeok97 authored Jan 9, 2024
2 parents c4e7f3f + 52ce973 commit 38f1ccf
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public Message delete(UserPrincipal userPrincipal, Long id) {
.build();
}

@Transactional
public ResponseCustom<?> findBookmarks(UserPrincipal userPrincipal) {
Optional<User> optionalUser = userRepository.findByEmail(userPrincipal.getEmail());

User user = optionalUser.get();
User user = userRepository.findByEmail(userPrincipal.getEmail())
.orElseThrow(RuntimeException::new);

List<PolicyInfoBookmark> bookmarks = policyInfoBookmarkRepository.findAllByUser(user);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import com.finfellows.domain.bookmark.domain.CmaBookmark;
import com.finfellows.domain.bookmark.domain.FinancialProductBookmark;
import com.finfellows.domain.product.domain.FinancialProduct;
import com.finfellows.domain.product.domain.FinancialProductOption;
import com.finfellows.domain.product.domain.FinancialProductType;
import lombok.Builder;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

Expand All @@ -15,35 +17,40 @@ public class FinancialProductBookmarkRes {
private FinancialProductType financialProductType;
private String companyName;
private String productName;
private Integer maxLimit;
private String maturityInterestRate;
private String interestRate;
private String maximumPreferredInterestRate;


@Builder
public FinancialProductBookmarkRes(FinancialProductType financialProductType, String companyName, String productName, Integer maxLimit, String maturityInterestRate) {
public FinancialProductBookmarkRes(FinancialProductType financialProductType, String companyName, String productName, String interestRate, String maximumPreferredInterestRate) {
this.financialProductType = financialProductType;
this.companyName = companyName;
this.productName = productName;
this.maxLimit = maxLimit;
this.maturityInterestRate = maturityInterestRate;
this.interestRate = interestRate;
this.maximumPreferredInterestRate = maximumPreferredInterestRate;
}


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

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

for (FinancialProductOption financialProductOption : financialProduct.getFinancialProductOption()) {
FinancialProductType financialProductType = financialProduct.getFinancialProductType();
String companyName = financialProduct.getCompanyName();
String productName = financialProduct.getProductName();
String interestRate = financialProductOption.getInterestRate();
String maximumPreferredInterestRate = financialProductOption.getMaximumPreferredInterestRate();

results.add(new FinancialProductBookmarkRes(financialProductType, companyName, productName, interestRate, maximumPreferredInterestRate));

}
}


public static List<FinancialProductBookmarkRes> toDto(List<FinancialProductBookmark> bookmarks) {
return bookmarks.stream()
.map(bookmark -> FinancialProductBookmarkRes.builder()
.financialProductType(bookmark.getFinancialProduct().getFinancialProductType())
.companyName(bookmark.getFinancialProduct().getCompanyName())
.productName(bookmark.getFinancialProduct().getProductName())
.maturityInterestRate(bookmark.getFinancialProduct().getMaturityInterestRate())
.maxLimit(bookmark.getFinancialProduct().getMaxLimit())
.build())
.collect(Collectors.toList());
return results;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Entity
@Table(name = "Financial_Product")
Expand Down Expand Up @@ -74,6 +75,9 @@ public class FinancialProduct extends BaseEntity {
@Column(name = "financial_product_type")
private FinancialProductType financialProductType;

@OneToMany(mappedBy = "financialProduct", fetch = FetchType.LAZY)
private List<FinancialProductOption> financialProductOption;

@Builder
public FinancialProduct(String financialCompanyNo, String financialProductCode, String topFinancialGroupNo, String disclosureMonth, String companyName, String productName, String joinWay, String maturityInterestRate, String specialCondition, Integer joinDeny, String joinMember, String etcNote, Integer maxLimit, LocalDate disclosureStartDay, LocalDate disclosureEndDay, LocalDateTime financialCompanySubmissionDay, FinancialProductType financialProductType) {
this.financialCompanyNo = financialCompanyNo;
Expand Down

0 comments on commit 38f1ccf

Please sign in to comment.