diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryCustom.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryCustom.java index 3039964..a49e07c 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryCustom.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryCustom.java @@ -11,7 +11,7 @@ public interface MissionPostRepositoryCustom { - List getMissionPostStepNumAndImage(Long farmClubId); + List getMissionPostStepNumAndImage(Long userId, Long farmClubId); GetMissionPostCommentResponseDto getMissionPostComment(Long missionPostId, Long userId); List getMissionPostList(Long userId, Long missionPostId); List getMissionPostHistory(Long missionPostId); diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryImpl.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryImpl.java index 316b1f9..abadd02 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryImpl.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryImpl.java @@ -29,7 +29,13 @@ public class MissionPostRepositoryImpl implements MissionPostRepositoryCustom { private final JPAQueryFactory queryFactory; @Override - public List getMissionPostStepNumAndImage(Long farmClubId) { + public List getMissionPostStepNumAndImage(Long userId, Long farmClubId) { + + List reportMissionPostIds = queryFactory + .select(missionPostReport.missionPost.id) + .from(missionPostReport) + .where(missionPostReport.user.id.eq(userId)) + .fetch(); return queryFactory .select(Projections.constructor( @@ -39,7 +45,7 @@ public List getMissionPostStepNumAndImage(Long farmClubId) .from(missionPost) .join(missionPost.userFarmClub, userFarmClub) .join(userFarmClub.farmClub, farmClub) - .where(farmClub.id.eq(farmClubId)) + .where(farmClub.id.eq(farmClubId).and(missionPost.id.notIn(reportMissionPostIds))) .fetch(); } @@ -75,6 +81,11 @@ public List getMissionPostList(Long userId, Long farmClubId) { .from(missionPostReport) .where(missionPostReport.user.id.eq(userId)) .fetch(); + List reportCommentIds = queryFactory + .select(missionPostCommentReport.missionPostComment.id) + .from(missionPostCommentReport) + .where(missionPostCommentReport.user.id.eq(userId)) + .fetch(); return queryFactory .select(new QMissionPostVo( @@ -85,7 +96,8 @@ public List getMissionPostList(Long userId, Long farmClubId) { .where(missionPostLike.missionPost.eq(missionPost)), JPAExpressions.select(missionPostComment.count()) .from(missionPostComment) - .where(missionPostComment.missionPost.eq(missionPost)), + .where(missionPostComment.missionPost.eq(missionPost) + .and(missionPostComment.id.notIn(reportCommentIds))), JPAExpressions.selectOne() .from(missionPostLike) .where(missionPostLike.missionPost.eq(missionPost) diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/FarmClubService.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/FarmClubService.java index 84dcbf7..5195a83 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/FarmClubService.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/FarmClubService.java @@ -132,7 +132,7 @@ public GetMyFarmClubResponseDto getMyFarmClub(Long farmClubId, Long userId) { List stepList = veggieInfoHelper.getStepList(veggieInfoId); String randomTip = getRandomTip(stepList, farmClubInfo.currentStep()); List missionList = - missionPostRepository.getMissionPostStepNumAndImage(farmClubId); + missionPostRepository.getMissionPostStepNumAndImage(userId, farmClubId); log.info("missionList: {}", missionList);