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 0e4817e..abd6411 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 399e9e8..180d27f 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 0000000..4f4eabd --- /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(); + } +}