diff --git a/src/main/java/Journey/Together/domain/plan/dto/PlanReviewRes.java b/src/main/java/Journey/Together/domain/plan/dto/PlanReviewRes.java index 44305e0..20a0c94 100644 --- a/src/main/java/Journey/Together/domain/plan/dto/PlanReviewRes.java +++ b/src/main/java/Journey/Together/domain/plan/dto/PlanReviewRes.java @@ -2,6 +2,7 @@ import jakarta.validation.constraints.Null; import lombok.Builder; +import software.amazon.awssdk.services.s3.endpoints.internal.Value; import java.util.List; @@ -19,11 +20,12 @@ public record PlanReviewRes( boolean hasReview, @Null List imageList, - String profileUrl + String profileUrl, + Boolean isReport ) { public static PlanReviewRes of(Long reviewId, String content, - Float grade,boolean isWriter,boolean hasReview,List imageList,String profileUrl){ + Float grade,boolean isWriter,boolean hasReview,List imageList,String profileUrl,Boolean isReport){ return PlanReviewRes.builder() .reviewId(reviewId) .content(content) @@ -32,6 +34,7 @@ public static PlanReviewRes of(Long reviewId, .hasReview(hasReview) .imageList(imageList) .profileUrl(profileUrl) + .isReport(isReport) .build(); } } diff --git a/src/main/java/Journey/Together/domain/plan/repository/PlanReviewRepository.java b/src/main/java/Journey/Together/domain/plan/repository/PlanReviewRepository.java index bbdf718..aaed30b 100644 --- a/src/main/java/Journey/Together/domain/plan/repository/PlanReviewRepository.java +++ b/src/main/java/Journey/Together/domain/plan/repository/PlanReviewRepository.java @@ -10,8 +10,11 @@ public interface PlanReviewRepository extends JpaRepository { boolean existsAllByPlan(Plan plan); + @Query("SELECT COUNT(pr) > 0 " + "FROM PlanReview pr " + "WHERE (pr.report IS NULL OR pr.report = false)") + boolean existsAllByPlanAndReportFillter(Plan plan); PlanReview findPlanReviewByPlan(Plan plan); - + @Query("SELECT pr FROM PlanReview pr WHERE pr.plan = :plan AND (pr.report IS NULL OR pr.report = false)") + PlanReview findPlanReviewByReportFillter(Plan plan); PlanReview findPlanReviewByPlanReviewId(Long id); PlanReview findPlanReviewByPlanAndDeletedAtIsNull(Plan plan); diff --git a/src/main/java/Journey/Together/domain/plan/service/PlanService.java b/src/main/java/Journey/Together/domain/plan/service/PlanService.java index b233b2f..55efac7 100644 --- a/src/main/java/Journey/Together/domain/plan/service/PlanService.java +++ b/src/main/java/Journey/Together/domain/plan/service/PlanService.java @@ -218,7 +218,7 @@ public PlanReviewRes findPlanReview(Member member,long planId){ if(plan == null){ throw new ApplicationException(ErrorCode.NOT_FOUND_EXCEPTION); } - PlanReview planReview = planReviewRepository.findPlanReviewByPlan(plan); + PlanReview planReview = planReviewRepository.findPlanReviewByReportFillter(plan); //Buisness boolean isWriter; if (member ==null){ @@ -229,9 +229,9 @@ public PlanReviewRes findPlanReview(Member member,long planId){ List imageList = getReviewImageList(plan); String profileUrl = s3Client.baseUrl()+plan.getMember().getProfileUuid()+"/profile_"+plan.getMember().getProfileUuid(); if(planReview==null){ - return PlanReviewRes.of(null,null,null,isWriter,false,imageList,profileUrl); + return PlanReviewRes.of(null,null,null,isWriter,false,imageList,profileUrl,planReview.getReport()); }else { - return PlanReviewRes.of(planReview.getPlanReviewId(),planReview.getContent(),planReview.getGrade(),isWriter,true,imageList,profileUrl); + return PlanReviewRes.of(planReview.getPlanReviewId(),planReview.getContent(),planReview.getGrade(),isWriter,true,imageList,profileUrl,planReview.getReport()); } } @@ -311,7 +311,7 @@ public List findMyPlans(Member member) { String remainDate = null; Boolean hasReview = null; if (LocalDate.now().isAfter(plan.getEndDate())){ - hasReview = planReviewRepository.existsAllByPlan(plan); + hasReview = planReviewRepository.existsAllByPlanAndReportFillter(plan); }else if ((LocalDate.now().isEqual(plan.getStartDate()) || LocalDate.now().isAfter(plan.getStartDate())) && (LocalDate.now().isEqual(plan.getEndDate()) || LocalDate.now().isBefore(plan.getEndDate()))){ remainDate="D-DAY"; }else if (LocalDate.now().isBefore(plan.getStartDate())){ @@ -344,7 +344,7 @@ public PlanPageRes findIsCompelete(Member member, Pageable page, Boolean compele if(compelete){ planPage = planRepository.findAllByMemberAndEndDateBeforeAndDeletedAtIsNull(member,LocalDate.now(),pageable); planResList = planPage.getContent().stream() - .map(plan -> PlanRes.of(plan,getPlaceFirstImage(plan),null,planReviewRepository.existsAllByPlan(plan))) + .map(plan -> PlanRes.of(plan,getPlaceFirstImage(plan),null,planReviewRepository.existsAllByPlanAndReportFillter(plan))) .collect(Collectors.toList()); }else { planPage = planRepository.findAllByMemberAndEndDateGreaterThanEqualAndDeletedAtIsNull(member,LocalDate.now(),pageable); @@ -415,7 +415,7 @@ public List getPlaceImageList(Plan plan){ public List getReviewImageList(Plan plan){ List list = new ArrayList<>(); - PlanReview planReview = planReviewRepository.findPlanReviewByPlan(plan); + PlanReview planReview = planReviewRepository.findPlanReviewByReportFillter(plan); List planReviewImageList = planReviewImageRepository.findAllByPlanReviewAndDeletedAtIsNull(planReview); for(PlanReviewImage planReviewImage : planReviewImageList){ list.add(planReviewImage.getImageUrl());