Skip to content

Commit

Permalink
Merge pull request #123 from Hanaemong/nayoung
Browse files Browse the repository at this point in the history
Fix: 총무변경 로직 수정
  • Loading branch information
ny2060 authored Jul 9, 2024
2 parents 5e104bc + c61eb7f commit ca0d511
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,24 @@ public void changeMeetingAccount(Long teamId,Long nextChairId) {
TeamMember curChair = teamMemberRepository.findTeamMemberByTeam_TeamIdAndRole(teamId, TeamMemberRole.CHAIR);
Account chairAccount = accountRepository.findAccountByMember_MemberId(curChair.getMember().getMemberId());

TeamMember nextChair = teamMemberRepository.findById(nextChairId).orElseThrow();
Account nextChairAccount = accountRepository.findAccountByMember_MemberId(nextChair.getMember().getMemberId());

/*모임통장 계좌 변경가능 확인*/

if(meetingAccountRepository.existsByAccount(chairAccount)) {
if(meetingAccountRepository.existsByAccount(nextChairAccount)) {
throw new NotChangeChairException();
}

/* role 변경*/
TeamMember nextChair = teamMemberRepository.findById(nextChairId).orElseThrow();

/* role 변경*/
curChair.changeRole(TeamMemberRole.REGULAR);
nextChair.changeRole(TeamMemberRole.CHAIR);
teamMemberRepository.save(curChair);
teamMemberRepository.save(nextChair);

/*총무 계좌와 다음 총무 계좌 변경*/
MeetingAccount meetingAccount = meetingAccountRepository.findMeetingAccountByAccount(chairAccount);
Account nextChairAccount = accountRepository.findAccountByMember_MemberId(nextChair.getMember().getMemberId());
meetingAccount.changeMeetingAccount(nextChairAccount);
meetingAccountRepository.save(meetingAccount);

Expand Down

0 comments on commit ca0d511

Please sign in to comment.