From 52fbe1e35dc5bf488024f4a27ad670386023f464 Mon Sep 17 00:00:00 2001 From: MinchoGreenT Date: Sat, 24 Aug 2024 17:38:49 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20=ED=8C=9C=ED=81=B4=EB=9F=BD=20=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20DB=20=EC=BF=BC?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/FarmClubRepositoryCustom.java | 3 ++- .../repository/FarmClubRepositoryImpl.java | 22 +++++++++++++++++++ .../domain/farmclub/vo/GetFarmClubUserVo.java | 17 ++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/GetFarmClubUserVo.java diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/FarmClubRepositoryCustom.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/FarmClubRepositoryCustom.java index 0e4817ec..abd6411f 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/FarmClubRepositoryCustom.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/FarmClubRepositoryCustom.java @@ -3,6 +3,7 @@ import com.modernfarmer.farmusspring.domain.farmclub.dto.res.GetMyFarmClubListResponseDto; import com.modernfarmer.farmusspring.domain.farmclub.dto.res.GetRecommendFarmClubResponseDto; import com.modernfarmer.farmusspring.domain.farmclub.entity.FarmClub; +import com.modernfarmer.farmusspring.domain.farmclub.vo.GetFarmClubUserVo; import com.modernfarmer.farmusspring.domain.farmclub.vo.GetMyFarmClubVo; import com.modernfarmer.farmusspring.domain.farmclub.dto.res.SearchFarmClubResponseDto; import com.modernfarmer.farmusspring.domain.history.vo.HistoryDetailVo; @@ -14,6 +15,6 @@ public interface FarmClubRepositoryCustom { List findMyFarmClubList(Long userId); GetMyFarmClubVo findMyFarmClub(Long farmClubId, Long userId); HistoryDetailVo getFarmClubDetail(Long userFarmClubId); - + List findFarmClubUserList(Long farmClubId); List getRecommendedFarmClubList(String level); } diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/FarmClubRepositoryImpl.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/FarmClubRepositoryImpl.java index 399e9e85..180d27f5 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/FarmClubRepositoryImpl.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/FarmClubRepositoryImpl.java @@ -5,11 +5,13 @@ import com.modernfarmer.farmusspring.domain.farmclub.entity.QFarmClub; import com.modernfarmer.farmusspring.domain.farmclub.exception.FarmClubErrorCode; import com.modernfarmer.farmusspring.domain.farmclub.exception.custom.FarmClubEntityNotFoundException; +import com.modernfarmer.farmusspring.domain.farmclub.vo.GetFarmClubUserVo; import com.modernfarmer.farmusspring.domain.farmclub.vo.GetMyFarmClubVo; import com.modernfarmer.farmusspring.domain.farmclub.vo.QGetMyFarmClubVo_BaseInfo; import com.modernfarmer.farmusspring.domain.history.vo.HistoryDetailVo; import com.modernfarmer.farmusspring.domain.history.vo.QHistoryDetailVo; import com.querydsl.core.Tuple; +import com.querydsl.core.types.Projections; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.JPAExpressions; import com.querydsl.jpa.impl.JPAQueryFactory; @@ -107,6 +109,26 @@ public GetMyFarmClubVo findMyFarmClub(Long farmClubId, Long userId) { return GetMyFarmClubVo.of(baseInfo, userFarmClubCount, currentStep, userFarmClubCreatedDate); } + @Override + public List findFarmClubUserList(Long farmClubId) { + JPAQueryFactory queryFactory = new JPAQueryFactory(em); + + return queryFactory + .select(Projections.constructor( + GetFarmClubUserVo.class, + user.nickname, + user.profileImage)) + .from(user) + .where(user.id.in( + JPAExpressions + .select(userFarmClub.userId) + .from(userFarmClub) + .join(userFarmClub.farmClub, farmClub) + .where(farmClub.id.eq(farmClubId)) + )) + .fetch(); + } + public HistoryDetailVo getFarmClubDetail(Long userFarmClubId) { JPAQueryFactory queryFactory = new JPAQueryFactory(em); diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/GetFarmClubUserVo.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/GetFarmClubUserVo.java new file mode 100644 index 00000000..4f4eabd9 --- /dev/null +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/GetFarmClubUserVo.java @@ -0,0 +1,17 @@ +package com.modernfarmer.farmusspring.domain.farmclub.vo; + +import lombok.AccessLevel; +import lombok.Builder; + +@Builder(access = AccessLevel.PRIVATE) +public record GetFarmClubUserVo( + String nickname, + String profileImage +) { + public static GetFarmClubUserVo of(String nickname, String profileImage) { + return GetFarmClubUserVo.builder() + .nickname(nickname) + .profileImage(profileImage) + .build(); + } +}