From 79d94497e594708b3c51c7191cf335e34fa3dd9b 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:00:10 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=AA=A8=EC=9E=84=20=EC=B4=88=EB=8C=80?= =?UTF-8?q?=20=EC=95=8C=EB=A6=BC=20api=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AccountTransactionDetails.java | 2 +- .../teamMember/controller/TeamMemberContoller.java | 8 ++++++-- .../teamMember/service/TeamMemberService.java | 5 +++-- .../service/impl/TeamMemberServiceImpl.java | 14 +++++++++++--- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/hanaro/triptogether/accountTransactionDetails/AccountTransactionDetails.java b/src/main/java/com/hanaro/triptogether/accountTransactionDetails/AccountTransactionDetails.java index cdf688b..5d39ed8 100644 --- a/src/main/java/com/hanaro/triptogether/accountTransactionDetails/AccountTransactionDetails.java +++ b/src/main/java/com/hanaro/triptogether/accountTransactionDetails/AccountTransactionDetails.java @@ -9,7 +9,7 @@ import java.time.LocalDateTime; @Entity -@Table(name = "Account_transaction_details") +@Table(name = "account_transaction_details") public class AccountTransactionDetails extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/com/hanaro/triptogether/teamMember/controller/TeamMemberContoller.java b/src/main/java/com/hanaro/triptogether/teamMember/controller/TeamMemberContoller.java index e20b44a..0fda3e9 100644 --- a/src/main/java/com/hanaro/triptogether/teamMember/controller/TeamMemberContoller.java +++ b/src/main/java/com/hanaro/triptogether/teamMember/controller/TeamMemberContoller.java @@ -1,5 +1,6 @@ package com.hanaro.triptogether.teamMember.controller; +import com.hanaro.triptogether.common.firebase.FirebaseFCMService; import com.hanaro.triptogether.teamMember.dto.request.*; import com.hanaro.triptogether.teamMember.dto.response.TeamMembersResDto; import com.hanaro.triptogether.teamMember.service.TeamMemberService; @@ -9,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; +import java.io.IOException; import java.util.List; import java.util.Map; @@ -16,6 +18,7 @@ @RequiredArgsConstructor public class TeamMemberContoller { private final TeamMemberService teamMemberService; + private final FirebaseFCMService firebaseFCMService; // 모임원 전체 출력 @PostMapping("/team") @@ -32,8 +35,9 @@ public void changeOwner(@RequestBody ChangeOwnerReqDto changeOwnerReqDto) { // 모임원 수락 (수락대기-> 모임원으로 상태 변경) @PutMapping("/team/accept-one") - public void acceptTeamMember(@RequestBody AcceptTeamMemberReqDto acceptTeamMemberReqDto) { + public void acceptTeamMember(@RequestBody AcceptTeamMemberReqDto acceptTeamMemberReqDto) throws IOException { teamMemberService.acceptTeamMember(acceptTeamMemberReqDto); + } // 모임원 전체 수락 (수락대기-> 모임원으로 상태 변경) @@ -68,7 +72,7 @@ public void exportTeamMembers(@RequestBody RejectTeamMembersReqDto rejectTeamMem // 모임 가입 @PostMapping("/team/join") - public void joinTeamMember(@RequestBody JoinTeamMemberReq joinTeamMemberReq) { + public void joinTeamMember(@RequestBody JoinTeamMemberReq joinTeamMemberReq) throws IOException { teamMemberService.joinTeamMember(joinTeamMemberReq); } } diff --git a/src/main/java/com/hanaro/triptogether/teamMember/service/TeamMemberService.java b/src/main/java/com/hanaro/triptogether/teamMember/service/TeamMemberService.java index 9e88ec8..15c65f4 100644 --- a/src/main/java/com/hanaro/triptogether/teamMember/service/TeamMemberService.java +++ b/src/main/java/com/hanaro/triptogether/teamMember/service/TeamMemberService.java @@ -5,6 +5,7 @@ import com.hanaro.triptogether.teamMember.dto.request.*; import com.hanaro.triptogether.teamMember.dto.response.TeamMembersResDto; +import java.io.IOException; import java.util.List; import java.util.Optional; @@ -16,7 +17,7 @@ public interface TeamMemberService { void changeOwner(ChangeOwnerReqDto changeOwnerReqDto); // 모임원 수락 (수락대기-> 모임원으로 상태 변경) - void acceptTeamMember(AcceptTeamMemberReqDto acceptTeamMemberReqDto); + void acceptTeamMember(AcceptTeamMemberReqDto acceptTeamMemberReqDto) throws IOException; // 모임원 전체 수락 (수락대기-> 모임원으로 상태 변경) void acceptTeamMembers(AcceptTeamMembersReqDto acceptTeamMembersReqDto); @@ -44,7 +45,7 @@ public interface TeamMemberService { void validateTeamMemberState(TeamMember teamMember); // 모임 가입 - void joinTeamMember(JoinTeamMemberReq joinTeamMemberReq); + void joinTeamMember(JoinTeamMemberReq joinTeamMemberReq) throws IOException; // 팀멤버idx로 팀멤버 검색 TeamMember checkIsMyTeamByTeamMemberIdx(Long team_member_idx); 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 52daa22..b95f684 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 @@ -1,8 +1,11 @@ package com.hanaro.triptogether.teamMember.service.impl; +import com.hanaro.triptogether.common.firebase.FirebaseFCMService; import com.hanaro.triptogether.enumeration.TeamMemberState; import com.hanaro.triptogether.exception.ApiException; import com.hanaro.triptogether.exception.ExceptionEnum; +import com.hanaro.triptogether.exchangeRate.dto.request.FcmSendDto; +import com.hanaro.triptogether.exchangeRate.exception.EntityNotFoundException; import com.hanaro.triptogether.member.domain.Member; import com.hanaro.triptogether.member.domain.MemberRepository; import com.hanaro.triptogether.team.domain.Team; @@ -16,6 +19,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.io.IOException; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -27,6 +31,7 @@ public class TeamMemberServiceImpl implements TeamMemberService { private final TeamMemberRepository teamMemberRepository; private final TeamRepository teamRepository; private final MemberRepository memberRepository; + private final FirebaseFCMService firebaseFCMService; // 모임원 전체 출력 @Transactional @@ -80,10 +85,10 @@ public void changeOwner(ChangeOwnerReqDto changeOwnerReqDto) { // 모임원 수락 (수락대기-> 모임원으로 상태 변경) @Transactional @Override - public void acceptTeamMember(AcceptTeamMemberReqDto acceptTeamMemberReqDto) { + 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.getMemberIdx()).orElseThrow(EntityNotFoundException::new); for(int i = 0; i < teamMembers.size(); i++) { if (acceptTeamMemberReqDto.getTeamMemberIdx().equals(teamMembers.get(i).getTeamMemberIdx())) { teamMembers.get(i).updateTeamMemberState(TeamMemberState.모임원); @@ -91,6 +96,8 @@ public void acceptTeamMember(AcceptTeamMemberReqDto acceptTeamMemberReqDto) { teamMemberRepository.save(teamMembers.get(i)); } } + firebaseFCMService.sendMessageTo(FcmSendDto.builder().token(member.getFcmToken()).title("모임 참여 승인 완료").body(team.getTeamName()+"모임에 가입되었습니다.").build()); + } // 모임원 전체 수락 (수락대기-> 모임원으로 상태 변경) @@ -189,7 +196,7 @@ public List findTeamMemberByMemberIdx(Long member_idx) { // 모임 가입 @Transactional @Override - public void joinTeamMember(JoinTeamMemberReq joinTeamMemberReq) { + public void joinTeamMember(JoinTeamMemberReq joinTeamMemberReq) throws IOException { Member member = memberRepository.findById(joinTeamMemberReq.getMemberIdx()).orElseThrow(() -> new ApiException(ExceptionEnum.MEMBER_NOT_FOUND)); Team team = teamRepository.findById(joinTeamMemberReq.getTeamIdx()).orElseThrow(() -> new ApiException(ExceptionEnum.TEAM_NOT_FOUND)); @@ -200,6 +207,7 @@ public void joinTeamMember(JoinTeamMemberReq joinTeamMemberReq) { .createdAt(LocalDateTime.now()).build(); teamMemberRepository.save(teamMember); + firebaseFCMService.sendMessageTo(FcmSendDto.builder().token(member.getFcmToken()).title("모임 참여 요청 알림").body(member.getMemberName()+"님이 "+team.getTeamName()+"모임에 참여하기를 원합니다.").build()); } @Override