From ac0402bc011e115ebd32ce2845143e55bc653620 Mon Sep 17 00:00:00 2001 From: msk226 Date: Tue, 27 Jan 2026 17:49:50 +0900 Subject: [PATCH] =?UTF-8?q?[Feature]=20=EC=9D=B4=EB=AF=B8=20=ED=83=88?= =?UTF-8?q?=ED=87=B4=ED=95=9C=20=EC=8A=A4=ED=84=B0=EB=94=94=EC=97=90=20?= =?UTF-8?q?=EC=9E=AC=EA=B0=80=EC=9E=85=20=EB=92=A4=20=ED=83=88=ED=87=B4?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EA=B2=BD=EC=9A=B0=EB=8F=84=20=EC=B2=B4?= =?UTF-8?q?=ED=81=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../study/application/command/WithdrawStudyService.java | 6 +++++- .../jpa/associations/StudyMemberRepository.java | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/study/src/main/java/kr/spot/study/application/command/WithdrawStudyService.java b/modules/study/src/main/java/kr/spot/study/application/command/WithdrawStudyService.java index f464685..a78ca44 100644 --- a/modules/study/src/main/java/kr/spot/study/application/command/WithdrawStudyService.java +++ b/modules/study/src/main/java/kr/spot/study/application/command/WithdrawStudyService.java @@ -5,6 +5,7 @@ import kr.spot.exception.GeneralException; import kr.spot.study.domain.Study; import kr.spot.study.domain.associations.StudyMember; +import kr.spot.study.domain.enums.StudyMemberStatus; import kr.spot.study.infrastructure.jpa.StudyRepository; import kr.spot.study.infrastructure.jpa.associations.StudyMemberRepository; import kr.spot.study.presentation.command.dto.request.WithdrawStudyRequest; @@ -20,7 +21,10 @@ public class WithdrawStudyService { private final StudyMemberRepository studyMemberRepository; public void withdrawStudy(long studyId, long memberId, WithdrawStudyRequest request) { - StudyMember studyMember = studyMemberRepository.getByMemberIdAndStudyId(memberId, studyId); + StudyMember studyMember = studyMemberRepository.getByMemberIdAndStudyIdAndStudyMemberStatusNot( + memberId, + studyId, + StudyMemberStatus.WITHDRAWN); Study study = studyRepository.getStudyById(studyId); StudyMember nextOwner = findNextOwner(studyId, request.nextOwnerId()); diff --git a/modules/study/src/main/java/kr/spot/study/infrastructure/jpa/associations/StudyMemberRepository.java b/modules/study/src/main/java/kr/spot/study/infrastructure/jpa/associations/StudyMemberRepository.java index 2a0ecd3..1ff705b 100644 --- a/modules/study/src/main/java/kr/spot/study/infrastructure/jpa/associations/StudyMemberRepository.java +++ b/modules/study/src/main/java/kr/spot/study/infrastructure/jpa/associations/StudyMemberRepository.java @@ -23,6 +23,15 @@ default StudyMember getByMemberIdAndStudyId(Long memberId, Long studyId) { .orElseThrow(() -> new GeneralException(ErrorStatus._STUDY_MEMBER_NOT_FOUND)); } + default StudyMember getByMemberIdAndStudyIdAndStudyMemberStatusNot(Long memberId, Long studyId, + StudyMemberStatus status) { + return findByMemberIdAndStudyIdAndStudyMemberStatusNot(memberId, studyId, status) + .orElseThrow(() -> new GeneralException(ErrorStatus._STUDY_MEMBER_NOT_FOUND)); + } + + Optional findByMemberIdAndStudyIdAndStudyMemberStatusNot(Long memberId, Long studyId, + StudyMemberStatus status); + Optional findByMemberIdAndStudyId(Long memberId, Long studyId); boolean existsByStudyIdAndMemberIdAndStudyMemberStatusIn(Long studyId, Long memberId,