Skip to content

Commit

Permalink
fix: 챌린지 참가하기 api - 모집인원 초과시 status==IMPOSSIBLE 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
daeunkwak committed Aug 26, 2023
1 parent 5244724 commit 9edab19
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ public Participate create(Long challengeId, Long memberId) {
participate.updateIsCreator();
}

return participateRepository.save(participate);
Participate newParticipate = participateRepository.save(participate);

challenge.getParticipates().add(newParticipate);
if(challenge.getParticipates().size() >= challenge.getChallengeCapacity()){
challenge.updateStatus(ChallengeStatus.IMPOSSIBLE);
}

return newParticipate;
}

// 챌린지 생성하기 - 생성자 참여
Expand Down
5 changes: 5 additions & 0 deletions cider-domain/src/main/java/com/cmc/challenge/Challenge.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ public Boolean isLike(Member member){
return false;
}

public void updateStatus(ChallengeStatus status){

this.challengeStatus = status;
}

// public boolean isCreator(Long memberId) {
//
// return this.member.getMemberId().equals(memberId);
Expand Down

0 comments on commit 9edab19

Please sign in to comment.