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

[FIX]액션 플랜 조회 시 리뷰가 달린 액션플랜인지 포함하여 반환 #73

Merged
merged 1 commit into from
Jan 16, 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 @@ -17,4 +17,6 @@ public class ActionPlanGetResponseDto {
private Boolean isScraped;

private Boolean isFinished;

private Boolean isReviewed;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사소한거지만, seed에 actionPlan이 있는지에 대한 변수명으로 hasActionPlan으로 개발했었어서 통일성을 위해 hasReview는 어떤지 여쭤보고 싶어요 ~!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 완전 좋은 의견이라고 생각합니다!!다음 PR에 얹어서 수정해놓겠습니다!! 감사합니당 :)

}
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);

}