From 747a33faed14e7fd29c2f81990c9647664018bc2 Mon Sep 17 00:00:00 2001 From: Hong0329 Date: Tue, 16 Jan 2024 06:08:30 +0900 Subject: [PATCH] =?UTF-8?q?[FIX]=EC=95=A1=EC=85=98=20=ED=94=8C=EB=9E=9C=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EB=A6=AC=EB=B7=B0=EA=B0=80=20?= =?UTF-8?q?=EB=8B=AC=EB=A6=B0=20=EC=95=A1=EC=85=98=ED=94=8C=EB=9E=9C?= =?UTF-8?q?=EC=9D=B8=EC=A7=80=20=ED=8F=AC=ED=95=A8=ED=95=98=EC=97=AC=20?= =?UTF-8?q?=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actionplan/dto/response/ActionPlanGetResponseDto.java | 2 ++ .../dto/response/DoingActionPlanGetResponseDto.java | 2 ++ .../dto/response/FinishedActionPlanGetResponseDto.java | 2 ++ .../actionplan/service/Impl/ActionPlanServiceImpl.java | 8 +++++--- .../api/review/repository/ReviewRepository.java | 2 ++ 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/dto/response/ActionPlanGetResponseDto.java b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/dto/response/ActionPlanGetResponseDto.java index 0026d9d..f34ccf1 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/dto/response/ActionPlanGetResponseDto.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/dto/response/ActionPlanGetResponseDto.java @@ -17,4 +17,6 @@ public class ActionPlanGetResponseDto { private Boolean isScraped; private Boolean isFinished; + + private Boolean isReviewed; } diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/dto/response/DoingActionPlanGetResponseDto.java b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/dto/response/DoingActionPlanGetResponseDto.java index 15654d8..6bdb694 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/dto/response/DoingActionPlanGetResponseDto.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/dto/response/DoingActionPlanGetResponseDto.java @@ -16,4 +16,6 @@ public class DoingActionPlanGetResponseDto { private Boolean isScraped; private Long seedId; + + private Boolean isReviewed; } diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/dto/response/FinishedActionPlanGetResponseDto.java b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/dto/response/FinishedActionPlanGetResponseDto.java index 8a2b0f2..a044521 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/dto/response/FinishedActionPlanGetResponseDto.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/dto/response/FinishedActionPlanGetResponseDto.java @@ -16,4 +16,6 @@ public class FinishedActionPlanGetResponseDto { private Boolean isScraped; private Long seedId; + + private Boolean isReviewed; } diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java index f1c540e..67535b4 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java @@ -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; @@ -29,6 +30,7 @@ public class ActionPlanServiceImpl implements ActionPlanService { private final ActionPlanRepository actionPlanRepository; private final SeedRepository seedRepository; + private final ReviewRepository reviewRepository; @Override @Transactional @@ -47,7 +49,7 @@ public List getActionPlan(Long seedId) { List 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()); } @@ -98,7 +100,7 @@ public List getDoingActionPlan(Long memberId) { List 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()); } @@ -107,7 +109,7 @@ public List getFinishedActionPlan(Long memberI List 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()); } } diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/review/repository/ReviewRepository.java b/growthookServer/src/main/java/com/example/growthookserver/api/review/repository/ReviewRepository.java index 704761f..ed5f7a1 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/review/repository/ReviewRepository.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/review/repository/ReviewRepository.java @@ -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; @@ -15,5 +16,6 @@ default Review findReviewByActionPlanIdOrThrow(Long actionPlanId) { return findReviewByActionPlanId(actionPlanId) .orElseThrow(() -> new NotFoundException(ErrorStatus.NOT_FOUND_REVIEW.getMessage())); } + boolean existsByActionPlan(ActionPlan actionPlan); }