Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<StudyMember> findByMemberIdAndStudyIdAndStudyMemberStatusNot(Long memberId, Long studyId,
StudyMemberStatus status);

Optional<StudyMember> findByMemberIdAndStudyId(Long memberId, Long studyId);

boolean existsByStudyIdAndMemberIdAndStudyMemberStatusIn(Long studyId, Long memberId,
Expand Down
Loading