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

[fix] #196 - promotion 조회 로직 수정 #197

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,19 @@ public HomeResponse getHomePerformanceList(HomeRequest homeRequest) {
private List<HomePromotionDetail> getPromotions() {
List<Promotion> promotionList = promotionRepository.findAll();
return promotionList.stream()
.map(promotion -> HomePromotionDetail.of(
promotion.getId(),
promotion.getPromotionPhoto(),
promotion.getPerformance().getId(),
promotion.getRedirectUrl(),
promotion.isExternal()
))
.map(promotion -> {
Long performanceId = null;
if (promotion.getPerformance() != null) {
performanceId = promotion.getPerformance().getId();
}
Comment on lines +223 to +226
Copy link
Member

Choose a reason for hiding this comment

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

확실히 getPerformance()가 null일 때, getId()를 하게 되면 NullPointerException이 발생해 500에러가 발생하는 것 같습니다.

이를 promotion.getPerformance()시 null이 아닐때만 getId()를 하도록 하신 점 너무 잘하신 것 같습니다!
고생하였습니다~

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

감사합니다ㅎㅎ

return HomePromotionDetail.of(
promotion.getId(),
promotion.getPromotionPhoto(),
performanceId,
promotion.getRedirectUrl(),
promotion.isExternal()
);
})
.collect(Collectors.toList());
}

Expand Down
Loading