From 4f81514851497527b09e17fdf61b6601319c397f Mon Sep 17 00:00:00 2001 From: swa07016 Date: Thu, 15 Aug 2024 18:14:36 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B2=BD=ED=92=88=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=A0=84=EC=B2=B4=20=EC=9D=91=EB=AA=A8=EC=9E=90?= =?UTF-8?q?=EC=88=98=20=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/PrizeCustomRepositoryImpl.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/nexters/dailyphrase/prize/domain/repository/PrizeCustomRepositoryImpl.java b/src/main/java/com/nexters/dailyphrase/prize/domain/repository/PrizeCustomRepositoryImpl.java index 599c8cf..0259dd7 100644 --- a/src/main/java/com/nexters/dailyphrase/prize/domain/repository/PrizeCustomRepositoryImpl.java +++ b/src/main/java/com/nexters/dailyphrase/prize/domain/repository/PrizeCustomRepositoryImpl.java @@ -34,8 +34,22 @@ public PrizeEventResponseDTO.PrizeList findPrizeListDTO(Long eventId) { Long memberId = memberUtils.getCurrentMemberId(); + JPQLQuery actualParticipantCountQuery = + JPAExpressions.select(qPrizeEntry.memberId.countDistinct()) + .from(qPrizeEntry) + .where(qPrizeEntry.prize.id.eq(qPrize.id)); + JPQLQuery totalParticipantCountQuery = - new JPAQuery().select(Expressions.constant(414L)); + new JPAQuery() + .select( + Expressions.cases() + .when(actualParticipantCountQuery.eq(0L)) + .then(Expressions.constant(414L)) + .otherwise( + Expressions.numberTemplate( + Long.class, + "414 + {0}", + actualParticipantCountQuery))); JPQLQuery myEntryCountQuery = JPAExpressions.select(qPrizeEntry.id.count())