From 44153c3149d3a4324a00927e2b1689ad57565b1d Mon Sep 17 00:00:00 2001 From: kang Date: Sun, 19 Feb 2023 13:51:28 +0900 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=EC=A4=91=EB=B3=B5=20=ED=94=BC?= =?UTF-8?q?=EB=93=9C=EB=B0=B1=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feedback/repository/FeedbackRepository.java | 4 ++++ .../allround3/feedback/service/FeedbackService.java | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/yapp/allround3/feedback/repository/FeedbackRepository.java b/src/main/java/yapp/allround3/feedback/repository/FeedbackRepository.java index 08f82b8..90ee165 100644 --- a/src/main/java/yapp/allround3/feedback/repository/FeedbackRepository.java +++ b/src/main/java/yapp/allround3/feedback/repository/FeedbackRepository.java @@ -4,11 +4,15 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; import yapp.allround3.feedback.domain.Feedback; +import yapp.allround3.participant.domain.Participant; import yapp.allround3.task.domain.Task; import java.util.List; +import java.util.Optional; @Repository public interface FeedbackRepository extends JpaRepository { List findByTask(Task task); + + Optional findByTaskAndParticipant(Task task, Participant participant); } diff --git a/src/main/java/yapp/allround3/feedback/service/FeedbackService.java b/src/main/java/yapp/allround3/feedback/service/FeedbackService.java index 88f4e82..b0dfdeb 100644 --- a/src/main/java/yapp/allround3/feedback/service/FeedbackService.java +++ b/src/main/java/yapp/allround3/feedback/service/FeedbackService.java @@ -47,6 +47,11 @@ public void saveFeedback(FeedbackRequest feedbackRequest) { throw new CustomException("자신의 업무는 피드백 할 수 없습니다."); } + if (existFeedbackHistory(task, participant)) { + throw new CustomException("이미 피드백을 제출하였습니다."); + } + + List checklist = feedbackRequest.getChecklist(); for (Integer templateId : checklist) { @@ -77,4 +82,9 @@ public CustomResponse findFeedbacks(Long taskId) { return CustomResponse.success(result); } + + private boolean existFeedbackHistory(Task task, Participant participant) { + return feedbackRepository.findByTaskAndParticipant(task, participant) + .isPresent(); + } }