From 5096d5905fbea01b038f3c7c61df47f958dad309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A1=E1=86=AB=E1=84=82=E1=85=A1=E1=84=8B?= =?UTF-8?q?=E1=85=A7=E1=86=BC?= Date: Mon, 10 Jun 2024 17:35:35 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=AA=A8=EC=9E=84=EC=B4=88=EB=8C=80=20?= =?UTF-8?q?=EC=88=98=EB=9D=BD/=EA=B1=B0=EC=A0=88=20api=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teamMember/domain/TeamMemberRepository.java | 2 ++ .../service/impl/TeamMemberServiceImpl.java | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) 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()); + }