Skip to content

Commit

Permalink
Merge pull request #122 from Mojacknong/feature_120/미션-인증-관련-이슈
Browse files Browse the repository at this point in the history
Feature 120/미션 인증 관련 이슈
  • Loading branch information
Ryeolee authored Sep 14, 2024
2 parents 22547dc + 16a6d0e commit 6d26535
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
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

0 comments on commit 6d26535

Please sign in to comment.