Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 120/미션 인증 관련 이슈 #122

Merged
merged 2 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public interface MissionPostRepositoryCustom {

List<GetMissionPostListVo> getMissionPostStepNumAndImage(Long farmClubId);
List<GetMissionPostListVo> getMissionPostStepNumAndImage(Long userId, Long farmClubId);
GetMissionPostCommentResponseDto getMissionPostComment(Long missionPostId, Long userId);
List<MissionPostVo> getMissionPostList(Long userId, Long missionPostId);
List<MissionPostHistoryVo> getMissionPostHistory(Long missionPostId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ public class MissionPostRepositoryImpl implements MissionPostRepositoryCustom {
private final JPAQueryFactory queryFactory;

@Override
public List<GetMissionPostListVo> getMissionPostStepNumAndImage(Long farmClubId) {
public List<GetMissionPostListVo> getMissionPostStepNumAndImage(Long userId, Long farmClubId) {

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

return queryFactory
.select(Projections.constructor(
Expand All @@ -39,7 +45,7 @@ public List<GetMissionPostListVo> 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();
}

Expand Down Expand Up @@ -75,6 +81,11 @@ public List<MissionPostVo> getMissionPostList(Long userId, Long farmClubId) {
.from(missionPostReport)
.where(missionPostReport.user.id.eq(userId))
.fetch();
List<Long> reportCommentIds = queryFactory
.select(missionPostCommentReport.missionPostComment.id)
.from(missionPostCommentReport)
.where(missionPostCommentReport.user.id.eq(userId))
.fetch();

return queryFactory
.select(new QMissionPostVo(
Expand All @@ -85,7 +96,8 @@ public List<MissionPostVo> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public GetMyFarmClubResponseDto getMyFarmClub(Long farmClubId, Long userId) {
List<StepVo> stepList = veggieInfoHelper.getStepList(veggieInfoId);
String randomTip = getRandomTip(stepList, farmClubInfo.currentStep());
List<GetMissionPostListVo> missionList =
missionPostRepository.getMissionPostStepNumAndImage(farmClubId);
missionPostRepository.getMissionPostStepNumAndImage(userId, farmClubId);

log.info("missionList: {}", missionList);

Expand Down
Loading