Skip to content

Commit

Permalink
✨ 강퇴시 재가입 불가
Browse files Browse the repository at this point in the history
  • Loading branch information
rilac1 committed Feb 23, 2023
1 parent 6080331 commit 6f747ba
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ public void dropParticipant(
throw new CustomException("팀원 내보내기는 팀장만 가능해요.");
}

participantService.withdrawProject(participantId);
participantService.dropProject(participantId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ public void join() {
participantStatus = ParticipantStatus.NORMAL;
}

public void drop() {
participantStatus = ParticipantStatus.DROPPED;
}

@Override
public String toString() {
return "Participant{" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
public enum ParticipantStatus {
NORMAL,
WITHDRAWAL,
DROPPED,
TEMP
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ public void joinProject(Long projectId, Long memberId) {
throw new CustomException("이미 가입된 참여자에요");
}

if (participant.getParticipantStatus() == ParticipantStatus.DROPPED) {
throw new CustomException("퇴장 당한 프로젝트에 참여할 수 없어요.");
}

participant.join();

// 피드백 필요 인원 증가
Expand Down Expand Up @@ -131,6 +135,16 @@ public void withdrawProject(Long participantId) {
.forEach(Task::subtractFeedbackRequiredPersonnel);
}

@Transactional
public void dropProject(Long participantId) {
Participant participant = findParticipantById(participantId);
participant.drop();

// 피드백 필요 인원 감축
taskRepository.findTasksByProjectId(participant.getProject().getId())
.forEach(Task::subtractFeedbackRequiredPersonnel);
}

@Transactional
public void withdrawAllProjects(Long memberId) {
Member member = memberService.findMemberById(memberId);
Expand Down

0 comments on commit 6f747ba

Please sign in to comment.