Skip to content

Commit

Permalink
[feat] 신고한 게시글 및 댓글은 조회되지 않도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
MinchoGreenT committed Sep 6, 2024
1 parent c3254ed commit 7c82ddc
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
import static com.modernfarmer.farmusspring.domain.farmclub.entity.QFarmClub.farmClub;
import static com.modernfarmer.farmusspring.domain.farmclub.entity.QMissionPost.missionPost;
import static com.modernfarmer.farmusspring.domain.farmclub.entity.QMissionPostComment.missionPostComment;
import static com.modernfarmer.farmusspring.domain.farmclub.entity.QMissionPostCommentReport.missionPostCommentReport;
import static com.modernfarmer.farmusspring.domain.farmclub.entity.QMissionPostLike.missionPostLike;
import static com.modernfarmer.farmusspring.domain.farmclub.entity.QMissionPostReport.missionPostReport;
import static com.modernfarmer.farmusspring.domain.farmclub.entity.QUserFarmClub.userFarmClub;
import static com.modernfarmer.farmusspring.domain.myveggiegarden.entity.QMyVeggie.myVeggie;
import static com.modernfarmer.farmusspring.domain.user.entity.QUser.user;
Expand All @@ -43,11 +45,17 @@ public List<GetMissionPostListVo> getMissionPostStepNumAndImage(Long farmClubId)

@Override
public GetMissionPostCommentResponseDto getMissionPostComment(Long missionPostId, Long userId) {
List<Long> reportCommentIds = queryFactory
.select(missionPostCommentReport.missionPostComment.id)
.from(missionPostCommentReport)
.where(missionPostCommentReport.user.id.eq(userId))
.fetch();

List<MissionPostCommentVo> comments = queryFactory
.select(new QMissionPostCommentVo(missionPostComment, user, Expressions.constant(userId)))
.from(missionPostComment)
.join(missionPostComment.missionPost, missionPost)
.where(missionPost.id.eq(missionPostId))
.where(missionPost.id.eq(missionPostId).and(missionPostComment.id.notIn(reportCommentIds)))
.fetch();

Boolean isMyPost = queryFactory
Expand All @@ -62,6 +70,12 @@ public GetMissionPostCommentResponseDto getMissionPostComment(Long missionPostId
@Override
public List<MissionPostVo> getMissionPostList(Long userId, Long farmClubId) {

List<Long> reportMissionPostIds = queryFactory
.select(missionPostReport.missionPost.id)
.from(missionPostReport)
.where(missionPostReport.user.id.eq(userId))
.fetch();

return queryFactory
.select(new QMissionPostVo(
missionPost,
Expand All @@ -82,7 +96,7 @@ public List<MissionPostVo> getMissionPostList(Long userId, Long farmClubId) {
.join(missionPost.userFarmClub, userFarmClub)
.join(userFarmClub.myVeggie, myVeggie)
.join(myVeggie.user, user)
.where(farmClub.id.eq(farmClubId))
.where(farmClub.id.eq(farmClubId).and(missionPost.id.notIn(reportMissionPostIds)))
.orderBy(missionPost.createdDate.desc())
.fetch();
}
Expand Down

0 comments on commit 7c82ddc

Please sign in to comment.