diff --git a/sunsu-wedding/src/main/java/com/kakao/sunsuwedding/_core/utils/PriceCalculator.java b/sunsu-wedding/src/main/java/com/kakao/sunsuwedding/_core/utils/PriceCalculator.java index f060ae21..342df2a9 100644 --- a/sunsu-wedding/src/main/java/com/kakao/sunsuwedding/_core/utils/PriceCalculator.java +++ b/sunsu-wedding/src/main/java/com/kakao/sunsuwedding/_core/utils/PriceCalculator.java @@ -28,6 +28,7 @@ public static Long calculateConfirmedQuotationPrice(List quotations) } public static Long calculateAvgPrice(List matches, Long contractCount) { + if (contractCount.equals(0L)) return 0L; return matches.stream() .filter(match -> match.getStatus().equals(MatchStatus.CONFIRMED)) .mapToLong(Match::getConfirmedPrice) diff --git a/sunsu-wedding/src/main/java/com/kakao/sunsuwedding/portfolio/PortfolioService.java b/sunsu-wedding/src/main/java/com/kakao/sunsuwedding/portfolio/PortfolioService.java index 4ffec8cd..34b7d34c 100644 --- a/sunsu-wedding/src/main/java/com/kakao/sunsuwedding/portfolio/PortfolioService.java +++ b/sunsu-wedding/src/main/java/com/kakao/sunsuwedding/portfolio/PortfolioService.java @@ -129,14 +129,19 @@ public PortfolioResponse.FindByIdDTO getPortfolioById(Long id) { throw new NotFoundException(BaseException.PORTFOLIO_NOT_FOUND); } + Portfolio portfolio = imageItems.get(0).getPortfolio(); + Planner planner = imageItems.get(0).getPortfolio().getPlanner(); + // 플래너 탈퇴 시 조회 X + if (planner == null) { + throw new NotFoundException(BaseException.PORTFOLIO_NOT_FOUND); + } + List images = imageItems .stream() .map(ImageEncoder::encode) .toList(); List priceItems = priceItemJPARepository.findAllByPortfolioId(id); - Portfolio portfolio = imageItems.get(0).getPortfolio(); - Planner planner = portfolio.getPlanner(); // 거래 내역 조회를 위한 매칭 내역, 견적서 가져오기 List matches = matchJPARepository.findLatestTenByPlanner(planner);