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 #206 from FinFellows/develop
Browse files Browse the repository at this point in the history
[FIX] financialProduct 중복 출력 제거
  • Loading branch information
LEEJaeHyeok97 authored Jan 17, 2024
2 parents ff5f6a2 + ac10d21 commit 90ee536
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import lombok.Data;

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

@Data
Expand Down Expand Up @@ -44,29 +46,36 @@ public FinancialProductBookmarkRes(Boolean isLiked, Long financialProductId, Fin

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

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

for (FinancialProductOption financialProductOption : financialProduct.getFinancialProductOption()) {
// financialProductId가 이미 포함되어 있으면 건너뛴다
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(financialProduct.getId())
.financialProductId(financialProductId)
.financialProductType(financialProduct.getFinancialProductType())
.companyName(bankName)
.productName(financialProduct.getProductName())
.interestRate(financialProductOption.getInterestRate())
.maximumPreferredInterestRate(financialProductOption.getMaximumPreferredInterestRate())
.interestRate(representativeOption.getInterestRate())
.maximumPreferredInterestRate(representativeOption.getMaximumPreferredInterestRate())
.bankLogoUrl(bankLogoUrl)
.build());

// financialProductId를 포함된 목록에 추가한다
includedFinancialProductIds.add(financialProductId);
}
}


return results;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,16 @@ public ResponseCustom<Message> deleteBookmarkCma(
}


// @Operation(summary = "모든 금융, 뭐하지 북마크 삭제", description = "Deletes all financial product and CMA bookmarks.")
// @ApiResponses(value = {
// @ApiResponse(responseCode = "200", description = "All bookmarks deleted successfully", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = Message.class))}),
// @ApiResponse(responseCode = "500", description = "Internal server error", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class))})
// })
// @DeleteMapping("/all")
// public ResponseCustom<?> deleteAllBookmarks() {
// bookmarkCleanupService.deleteAllBookmarks();
// return ResponseCustom.OK(new Message("All bookmarks deleted successfully."));
// }
@Operation(summary = "모든 금융, 뭐하지 북마크 삭제", description = "Deletes all financial product and CMA bookmarks.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "All bookmarks deleted successfully", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = Message.class))}),
@ApiResponse(responseCode = "500", description = "Internal server error", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class))})
})
@DeleteMapping("/all")
public ResponseCustom<?> deleteAllBookmarks() {
bookmarkCleanupService.deleteAllBookmarks();
return ResponseCustom.OK(new Message("All bookmarks deleted successfully."));
}

// @Operation(summary = "금융, 고마워 북마크 삭제", description = "Deletes all policyInfos.")
// @ApiResponses(value = {
Expand Down

0 comments on commit 90ee536

Please sign in to comment.