Skip to content

Commit

Permalink
[FIX]액션 플랜 조회 시 리뷰가 달린 액션플랜인지 포함하여 반환
Browse files Browse the repository at this point in the history
  • Loading branch information
Hong0329 committed Jan 15, 2024
1 parent 860ac65 commit 747a33f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ public class ActionPlanGetResponseDto {
private Boolean isScraped;

private Boolean isFinished;

private Boolean isReviewed;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ public class DoingActionPlanGetResponseDto {
private Boolean isScraped;

private Long seedId;

private Boolean isReviewed;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ public class FinishedActionPlanGetResponseDto {
private Boolean isScraped;

private Long seedId;

private Boolean isReviewed;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.example.growthookserver.api.actionplan.repository.ActionPlanRepository;
import com.example.growthookserver.api.actionplan.service.ActionPlanService;
import com.example.growthookserver.api.member.domain.Member;
import com.example.growthookserver.api.review.repository.ReviewRepository;
import com.example.growthookserver.api.seed.domain.Seed;
import com.example.growthookserver.api.seed.repository.SeedRepository;
import com.example.growthookserver.common.exception.BadRequestException;
Expand All @@ -29,6 +30,7 @@ public class ActionPlanServiceImpl implements ActionPlanService {

private final ActionPlanRepository actionPlanRepository;
private final SeedRepository seedRepository;
private final ReviewRepository reviewRepository;

@Override
@Transactional
Expand All @@ -47,7 +49,7 @@ public List<ActionPlanGetResponseDto> getActionPlan(Long seedId) {
List<ActionPlan> actionPlans = actionPlanRepository.findAllBySeedId(seedId);

return actionPlans.stream()
.map(actionPlan -> ActionPlanGetResponseDto.of(actionPlan.getId(), actionPlan.getContent(), actionPlan.getIsScraped(), actionPlan.getIsFinished()))
.map(actionPlan -> ActionPlanGetResponseDto.of(actionPlan.getId(), actionPlan.getContent(), actionPlan.getIsScraped(), actionPlan.getIsFinished(),reviewRepository.existsByActionPlan(actionPlan)))
.collect(Collectors.toList());
}

Expand Down Expand Up @@ -98,7 +100,7 @@ public List<DoingActionPlanGetResponseDto> getDoingActionPlan(Long memberId) {
List<ActionPlan> doingActionPlans = actionPlanRepository.findAllBySeedCaveMemberIdAndIsFinished(memberId,false);

return doingActionPlans.stream()
.map(actionPlan -> DoingActionPlanGetResponseDto.of(actionPlan.getId(), actionPlan.getContent(), actionPlan.getIsScraped(),actionPlan.getSeed().getId()))
.map(actionPlan -> DoingActionPlanGetResponseDto.of(actionPlan.getId(), actionPlan.getContent(), actionPlan.getIsScraped(),actionPlan.getSeed().getId(),reviewRepository.existsByActionPlan(actionPlan)))
.collect(Collectors.toList());
}

Expand All @@ -107,7 +109,7 @@ public List<FinishedActionPlanGetResponseDto> getFinishedActionPlan(Long memberI
List<ActionPlan> finishedActionPlans = actionPlanRepository.findAllBySeedCaveMemberIdAndIsFinished(memberId,true);

return finishedActionPlans.stream()
.map(actionPlan -> FinishedActionPlanGetResponseDto.of(actionPlan.getId(), actionPlan.getContent(), actionPlan.getIsScraped(),actionPlan.getSeed().getId()))
.map(actionPlan -> FinishedActionPlanGetResponseDto.of(actionPlan.getId(), actionPlan.getContent(), actionPlan.getIsScraped(),actionPlan.getSeed().getId(),reviewRepository.existsByActionPlan(actionPlan)))
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.growthookserver.api.review.repository;

import com.example.growthookserver.api.actionplan.domain.ActionPlan;
import com.example.growthookserver.api.cave.domain.Cave;
import com.example.growthookserver.api.review.domain.Review;
import com.example.growthookserver.common.exception.NotFoundException;
Expand All @@ -15,5 +16,6 @@ default Review findReviewByActionPlanIdOrThrow(Long actionPlanId) {
return findReviewByActionPlanId(actionPlanId)
.orElseThrow(() -> new NotFoundException(ErrorStatus.NOT_FOUND_REVIEW.getMessage()));
}
boolean existsByActionPlan(ActionPlan actionPlan);

}

0 comments on commit 747a33f

Please sign in to comment.