From b820b589ab1c772777492ed68c5613fdb5cb2876 Mon Sep 17 00:00:00 2001 From: Donghun Won Date: Mon, 23 Sep 2024 17:33:37 +0900 Subject: [PATCH] =?UTF-8?q?Fix=20:=20=EB=A7=88=EC=9D=B4=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=EB=AA=A8=EC=9E=84=20=EC=A1=B0=ED=9A=8C=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95=20(#207)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix : 삭제된 모임 조회되지 않도록 수정 * Fix : 모임 인원수 오류 수정 자기자신을 인원에 포함하지 않는 문제 여러명의 인원을 1명으로 인식하는 문제 --- .../user/repository/UserRepositoryImpl.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/main/java/solitour_backend/solitour/user/repository/UserRepositoryImpl.java b/src/main/java/solitour_backend/solitour/user/repository/UserRepositoryImpl.java index 6a4193b..0ee5b1d 100644 --- a/src/main/java/solitour_backend/solitour/user/repository/UserRepositoryImpl.java +++ b/src/main/java/solitour_backend/solitour/user/repository/UserRepositoryImpl.java @@ -5,6 +5,7 @@ import com.querydsl.core.types.dsl.CaseBuilder; import com.querydsl.core.types.dsl.Expressions; import com.querydsl.core.types.dsl.NumberExpression; +import com.querydsl.core.types.dsl.NumberPath; import com.querydsl.core.types.dsl.StringExpression; import com.querydsl.jpa.JPAExpressions; import com.querydsl.jpa.JPQLQuery; @@ -149,7 +150,7 @@ public Page retrieveGatheringHost(Pageable pageable, Lo .on(gatheringApplicants.gathering.id.eq(gathering.id) .and(gatheringApplicants.gatheringStatus.eq(GatheringStatus.CONSENT))) .orderBy(gathering.createdAt.desc()) - .where(gathering.user.id.eq(userId)); + .where(gathering.user.id.eq(userId).and(gathering.isDeleted.eq(false))); List list = query .groupBy(gathering.id, zoneCategoryParent.id, zoneCategoryChild.id, @@ -200,7 +201,7 @@ public Page retrieveGatheringBookmark(Pageable pageable .leftJoin(bookMarkGathering) .on(bookMarkGathering.gathering.id.eq(gathering.id)) .orderBy(gathering.createdAt.desc()) - .where(bookMarkGathering.user.id.eq(userId)); + .where(bookMarkGathering.user.id.eq(userId).and(gathering.isDeleted.eq(false))); List list = query .groupBy(gathering.id, zoneCategoryParent.id, zoneCategoryChild.id, @@ -240,7 +241,7 @@ public Page retrieveGatheringApplicant(Pageable page NumberExpression likeCount = countGreatGatheringByGatheringById(); BooleanExpression isBookMark = isGatheringBookmark(userId); StringExpression gatheringStatus = getGatheringStatus(); - NumberExpression gatheringApplicantCount = countGatheringApplicant(userId); + NumberExpression gatheringApplicantCount = countGatheringApplicant(gathering.id); JPQLQuery query = from(gathering) .leftJoin(zoneCategoryParent) @@ -250,7 +251,7 @@ public Page retrieveGatheringApplicant(Pageable page .leftJoin(gatheringApplicants) .on(gatheringApplicants.gathering.id.eq(gathering.id)) .orderBy(gathering.createdAt.desc()) - .where(gatheringApplicants.user.id.eq(userId).and(gathering.user.id.eq(userId).not())); + .where(gatheringApplicants.user.id.eq(userId).and(gathering.user.id.eq(userId).not()).and(gathering.isDeleted.eq(false))); List list = query .groupBy(gathering.id, zoneCategoryParent.id, zoneCategoryChild.id, @@ -273,7 +274,8 @@ public Page retrieveGatheringApplicant(Pageable page gathering.startAge, gathering.endAge, gathering.personCount, - gatheringApplicantCount, isUserGreatGathering(userId), + gatheringApplicantCount, + isUserGreatGathering(userId), gatheringStatus, gathering.isFinish )) @@ -285,18 +287,17 @@ gatheringApplicantCount, isUserGreatGathering(userId), return new PageImpl<>(list, pageable, total); } - private NumberExpression countGatheringApplicant(Long userId) { + private NumberExpression countGatheringApplicant(NumberPath gatheringId) { QGatheringApplicants gatheringApplicants = QGatheringApplicants.gatheringApplicants; - JPQLQuery countApplicant = JPAExpressions - .select(gatheringApplicants.count()) + JPQLQuery countApplicant = JPAExpressions + .select(gatheringApplicants.count().intValue()) .from(gatheringApplicants) - .where(gatheringApplicants.user.id.eq(userId) + .where(gatheringApplicants.gathering.id.eq(gatheringId) .and(gatheringApplicants.gatheringStatus.eq(GatheringStatus.CONSENT))); - return Expressions.numberTemplate(Long.class, "{0}", countApplicant) - .coalesce(0L) - .intValue(); + return Expressions.numberTemplate(Integer.class, "{0}", countApplicant) + .coalesce(0); } @Override