From 7c0bcbd9cfed95a43f5ba322dadbd839c0c0fa64 Mon Sep 17 00:00:00 2001 From: zionhann Date: Mon, 18 Mar 2024 00:52:31 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=92=A4=EB=8A=A6=EA=B2=8C=20=EC=8B=A0?= =?UTF-8?q?=EC=B2=AD=ED=95=9C=20=EC=83=81=EB=8C=80=EC=9D=98=20=EC=B9=9C?= =?UTF-8?q?=EA=B5=AC=20=EC=84=A0=ED=83=9D=20=EC=83=81=ED=83=9C=EA=B0=80=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20?= =?UTF-8?q?=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95=20(#153)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../csee/histudy/domain/StudyApplicant.java | 2 +- .../csee/histudy/service/UserService.java | 20 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main/java/edu/handong/csee/histudy/domain/StudyApplicant.java b/src/main/java/edu/handong/csee/histudy/domain/StudyApplicant.java index 82800f3..6145f94 100644 --- a/src/main/java/edu/handong/csee/histudy/domain/StudyApplicant.java +++ b/src/main/java/edu/handong/csee/histudy/domain/StudyApplicant.java @@ -48,7 +48,7 @@ public static StudyApplicant of( return applicant; } - public void changeStatusIfPartnerRequested( + public void changeStatusIfReceivedBy( User user, Function changeStatus) { this.partnerRequests.stream() .filter(request -> request.isReceivedBy(user)) diff --git a/src/main/java/edu/handong/csee/histudy/service/UserService.java b/src/main/java/edu/handong/csee/histudy/service/UserService.java index b6e1a65..bc33c8e 100644 --- a/src/main/java/edu/handong/csee/histudy/service/UserService.java +++ b/src/main/java/edu/handong/csee/histudy/service/UserService.java @@ -57,9 +57,12 @@ public ApplyFormDto apply(ApplyForm form, String email) { studyApplicantRepository .findByUserAndTerm(partner, currentTerm) .ifPresent( - partnerApplication -> - partnerApplication.changeStatusIfPartnerRequested( - user, StudyPartnerRequest::accept))); + partnerApplication -> { + partnerApplication.changeStatusIfReceivedBy( + user, StudyPartnerRequest::accept); + + applicant.changeStatusIfReceivedBy(partner, StudyPartnerRequest::accept); + })); studyApplicantRepository.save(applicant); return new ApplyFormDto(applicant); } @@ -88,9 +91,12 @@ public StudyApplicant apply(List friendsIds, List courseIds, String studyApplicantRepository .findByUserAndTerm(partner, currentTerm) .ifPresent( - partnerApplication -> - partnerApplication.changeStatusIfPartnerRequested( - user, StudyPartnerRequest::accept))); + partnerApplication -> { + partnerApplication.changeStatusIfReceivedBy( + user, StudyPartnerRequest::accept); + + applicant.changeStatusIfReceivedBy(partner, StudyPartnerRequest::accept); + })); return studyApplicantRepository.save(applicant); } @@ -109,7 +115,7 @@ private void removeFormHistoryIfExists(User user, AcademicTerm currentTerm) { .findByUserAndTerm(receiver, currentTerm) .ifPresent( partnerApplication -> - partnerApplication.changeStatusIfPartnerRequested( + partnerApplication.changeStatusIfReceivedBy( user, StudyPartnerRequest::unfriend)); } studyApplicantRepository.delete(applicant);