diff --git a/src/main/java/com/hanaro/triptogether/teamMember/domain/TeamMemberRepository.java b/src/main/java/com/hanaro/triptogether/teamMember/domain/TeamMemberRepository.java index e9a3bd2..541ff96 100644 --- a/src/main/java/com/hanaro/triptogether/teamMember/domain/TeamMemberRepository.java +++ b/src/main/java/com/hanaro/triptogether/teamMember/domain/TeamMemberRepository.java @@ -26,4 +26,6 @@ public interface TeamMemberRepository extends JpaRepository { TeamMember findTeamMemberByMemberAndTeam(Member member, Team team); + TeamMember findTeamMemberByTeamMemberState(String teamMemberState); + } diff --git a/src/main/java/com/hanaro/triptogether/teamMember/service/impl/TeamMemberServiceImpl.java b/src/main/java/com/hanaro/triptogether/teamMember/service/impl/TeamMemberServiceImpl.java index cf4a778..e4042b2 100644 --- a/src/main/java/com/hanaro/triptogether/teamMember/service/impl/TeamMemberServiceImpl.java +++ b/src/main/java/com/hanaro/triptogether/teamMember/service/impl/TeamMemberServiceImpl.java @@ -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 teamMembers = teamMemberRepository.findTeamMembersByTeam(team); - Member member = memberRepository.findById(acceptTeamMemberReqDto.getTeamMemberIdx()).orElseThrow(EntityNotFoundException::new); + TeamMember member = teamMemberRepository.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.모임원); @@ -96,7 +96,7 @@ public void acceptTeamMember(AcceptTeamMemberReqDto acceptTeamMemberReqDto) thro teamMemberRepository.save(teamMembers.get(i)); } } - firebaseFCMService.sendMessageTo(FcmSendDto.builder().token(member.getFcmToken()).title("모임 참여 승인 완료").body(team.getTeamName()+"모임에 가입되었습니다.").build()); + firebaseFCMService.sendMessageTo(FcmSendDto.builder().token(member.getMember().getFcmToken()).title("모임 참여 승인 완료").body(team.getTeamName()+"모임에 가입되었습니다.").build()); } @@ -204,11 +204,14 @@ public void joinTeamMember(JoinTeamMemberReq joinTeamMemberReq) throws IOExcepti Team team = teamRepository.findById(joinTeamMemberReq.getTeamIdx()).orElseThrow(() -> new ApiException(ExceptionEnum.TEAM_NOT_FOUND)); TeamMember existingTeamMember = teamMemberRepository.findTeamMemberByMemberAndTeam(member, team); - + TeamMember teamBossMember = teamMemberRepository.findTeamMemberByTeamMemberState("총무"); if (existingTeamMember != null) { existingTeamMember.updateTeamMemberState(TeamMemberState.수락대기); existingTeamMember.delete(null, null); teamMemberRepository.save(existingTeamMember); + if (existingTeamMember.getTeamMemberState().equals("총무")) { + firebaseFCMService.sendMessageTo(FcmSendDto.builder().token(teamBossMember.getMember().getFcmToken()).title("모임 참여 요청 알림").body(member.getMemberName()+"님이 "+team.getTeamName()+"모임에 참여하기를 원합니다.").build()); + } } else { TeamMember teamMember = TeamMember.builder() .team(team) @@ -218,7 +221,7 @@ public void joinTeamMember(JoinTeamMemberReq joinTeamMemberReq) throws IOExcepti .build(); teamMemberRepository.save(teamMember); } - firebaseFCMService.sendMessageTo(FcmSendDto.builder().token(member.getFcmToken()).title("모임 참여 요청 알림").body(member.getMemberName()+"님이 "+team.getTeamName()+"모임에 참여하기를 원합니다.").build()); + }