Skip to content

Commit

Permalink
fix: 모임 초대 수락/거절 api 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
ny2060 committed Jun 10, 2024
1 parent f1818ee commit a363fcc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void acceptTeamMembers(@RequestBody AcceptTeamMembersReqDto acceptTeamMem

// 모임원 거절 (수락대기-> 모임원 삭제)
@PutMapping("/team/reject-one")
public void rejectTeamMember(@RequestBody AcceptTeamMemberReqDto acceptTeamMemberReqDto) {
public void rejectTeamMember(@RequestBody AcceptTeamMemberReqDto acceptTeamMemberReqDto) throws IOException {
teamMemberService.rejectTeamMember(acceptTeamMemberReqDto);
}

Expand All @@ -60,7 +60,7 @@ public void rejectTeamMembers(@RequestBody RejectTeamMembersReqDto rejectTeamMem

// 모임원 내보내기 (모임원-> 모임원 삭제)
@PutMapping("/team/export-member")
public void exportTeamMember(@RequestBody AcceptTeamMemberReqDto acceptTeamMemberReqDto) {
public void exportTeamMember(@RequestBody AcceptTeamMemberReqDto acceptTeamMemberReqDto) throws IOException {
teamMemberService.rejectTeamMember(acceptTeamMemberReqDto);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public interface TeamMemberService {

// 모임원 거절 (수락대기-> 모임원 삭제)
// 모임원 내보내기 (모임원-> 모임원 삭제)
void rejectTeamMember(AcceptTeamMemberReqDto acceptTeamMemberReqDto);
void rejectTeamMember(AcceptTeamMemberReqDto acceptTeamMemberReqDto) throws IOException;

// 모임원 전체 거절 (수락대기-> 모임원 삭제)
void rejectTeamMembers(RejectTeamMembersReqDto rejectTeamMembersReqDto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void changeOwner(ChangeOwnerReqDto changeOwnerReqDto) {
public void acceptTeamMember(AcceptTeamMemberReqDto acceptTeamMemberReqDto) throws IOException {
Team team = teamRepository.findById(acceptTeamMemberReqDto.getTeamIdx()).orElseThrow(() -> new ApiException(ExceptionEnum.TEAM_NOT_FOUND));
List<TeamMember> teamMembers = teamMemberRepository.findTeamMembersByTeam(team);
Member member = memberRepository.findById(acceptTeamMemberReqDto.getMemberIdx()).orElseThrow(EntityNotFoundException::new);
Member member = memberRepository.findById(acceptTeamMemberReqDto.getTeamMemberIdx()).orElseThrow(EntityNotFoundException::new);
for(int i = 0; i < teamMembers.size(); i++) {
if (acceptTeamMemberReqDto.getTeamMemberIdx().equals(teamMembers.get(i).getTeamMemberIdx())) {
teamMembers.get(i).updateTeamMemberState(TeamMemberState.모임원);
Expand Down Expand Up @@ -120,17 +120,20 @@ public void acceptTeamMembers(AcceptTeamMembersReqDto acceptTeamMembersReqDto) {
// 모임원 내보내기 (모임원-> 모임원 삭제)
@Transactional
@Override
public void rejectTeamMember(AcceptTeamMemberReqDto acceptTeamMemberReqDto) {
public void rejectTeamMember(AcceptTeamMemberReqDto acceptTeamMemberReqDto) throws IOException {
Team team = teamRepository.findById(acceptTeamMemberReqDto.getTeamIdx()).orElseThrow(() -> new ApiException(ExceptionEnum.TEAM_NOT_FOUND));
List<TeamMember> teamMembers = teamMemberRepository.findTeamMembersByTeam(team);

Member member = memberRepository.findById(acceptTeamMemberReqDto.getTeamMemberIdx()).orElseThrow(EntityNotFoundException::new);
for(int i = 0; i < teamMembers.size(); i++) {
if (acceptTeamMemberReqDto.getTeamMemberIdx().equals(teamMembers.get(i).getTeamMemberIdx())) {
teamMembers.get(i).updateTeamMemberState(TeamMemberState.거절);
teamMembers.get(i).delete(LocalDateTime.now(), acceptTeamMemberReqDto.getMemberIdx());
teamMemberRepository.save(teamMembers.get(i));
}
}

firebaseFCMService.sendMessageTo(FcmSendDto.builder().token(member.getFcmToken()).title("모임 참여 거절").body(team.getTeamName()+"모임가입에 거절되었습니다.").build());

}

// 모임원 전체 거절 (수락대기-> 모임원 삭제)
Expand Down

0 comments on commit a363fcc

Please sign in to comment.