Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[]feat(brand) : 실시간 상품 최저가 조회 쿼리 변경 #115

Merged
merged 8 commits into from
Oct 24, 2024

Conversation

hgalchi
Copy link
Member

@hgalchi hgalchi commented Oct 24, 2024

#️⃣연관된 이슈

📝작업 내용

상품 최저가 할인율 조회 쿼리 변경하였습니다.

스크린샷 (선택)

💬리뷰 요구사항(선택)

image
<변경 전>
image
<변경 후>

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요?

@wonowonow
Copy link
Member

@Override
    public List<TimeSaleProductResponseDto> getMaxDiscountTimeSaleProductHasStock(List<String> productIds) {

        if (productIds.size() > 100) {
            throw new BusinessException(ExceptionMessage.REQUEST_LIST_SIZE_LIMIT);
        }

        List<TimeSaleProductResponseDto> allTimeSaleProducts = timeSaleReader.readByProductIds(productIds).stream()
                .flatMap(timeSale -> timeSale.getTimeSaleProducts().stream())
                .map(timeSaleProductMapper::toDto)
                .toList();


        List<TimeSaleProductResponseDto> availableStockProducts = allTimeSaleProducts.stream()
                .filter(product -> product.saleQuantity() < product.totalQuantity())
                .toList();


        Map<String, TimeSaleProductResponseDto> maxDiscountProducts = availableStockProducts.stream()
                .collect(Collectors.toMap(
                        TimeSaleProductResponseDto::productId,
                        Function.identity(),
                        (existing, replacement) -> replacement.discountRate() > existing.discountRate() ? replacement : existing
                ));

        return productIds.stream()
                .filter(maxDiscountProducts::containsKey)
                .map(maxDiscountProducts::get)
                .toList(); // 리턴 수정
    }

기존 코드에서 이렇게 수정만 하면 되지 않을까요?

Copy link
Member

@yunjae62 yunjae62 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다 !!

@hgalchi hgalchi self-assigned this Oct 24, 2024
@hgalchi hgalchi merged commit 6ad0da6 into main Oct 24, 2024
1 check passed
@hgalchi hgalchi deleted the feat/saga-pattern branch October 24, 2024 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants