From 8dc654d12420f67740b6221ad19d560af0626c07 Mon Sep 17 00:00:00 2001 From: minsu20 Date: Mon, 4 Dec 2023 19:14:32 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=ED=8C=80=20=ED=83=88=ED=87=B4?= =?UTF-8?q?=ED=95=9C=20=ED=9A=8C=EC=9B=90=EC=97=90=EA=B2=8C=20=EC=95=8C?= =?UTF-8?q?=EB=A6=BC=20=EC=95=88=EA=B0=80=EA=B2=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/TeamMemberCustomRepository.java | 1 - .../repository/TeamMemberCustomRepositoryImpl.java | 14 ++------------ .../domain/service/TeamMemberGetService.java | 4 ---- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/moing/backend/domain/teamMember/domain/repository/TeamMemberCustomRepository.java b/src/main/java/com/moing/backend/domain/teamMember/domain/repository/TeamMemberCustomRepository.java index ff212d46..89b22d3b 100644 --- a/src/main/java/com/moing/backend/domain/teamMember/domain/repository/TeamMemberCustomRepository.java +++ b/src/main/java/com/moing/backend/domain/teamMember/domain/repository/TeamMemberCustomRepository.java @@ -10,7 +10,6 @@ public interface TeamMemberCustomRepository { List findMemberIdsByTeamId(Long teamId); Optional> findFcmTokensByTeamIdAndMemberId(Long teamId, Long memberId); - Optional> findFcmTokensByTeamId(Long teamId); List findTeamMemberInfoByTeamId(Long teamId); List findTeamMemberByMemberId(Long memberId); } diff --git a/src/main/java/com/moing/backend/domain/teamMember/domain/repository/TeamMemberCustomRepositoryImpl.java b/src/main/java/com/moing/backend/domain/teamMember/domain/repository/TeamMemberCustomRepositoryImpl.java index b692fcee..7942c58f 100644 --- a/src/main/java/com/moing/backend/domain/teamMember/domain/repository/TeamMemberCustomRepositoryImpl.java +++ b/src/main/java/com/moing/backend/domain/teamMember/domain/repository/TeamMemberCustomRepositoryImpl.java @@ -37,18 +37,8 @@ public Optional> findFcmTokensByTeamIdAndMemberId(Long teamId, Long .from(teamMember) .where(teamMember.team.teamId.eq(teamId) .and(teamMember.member.isNewUploadPush.eq(true)) - .and(teamMember.member.memberId.ne(memberId))) - .fetch(); - - return result.isEmpty() ? Optional.empty() : Optional.of(result); - } - - @Override - public Optional> findFcmTokensByTeamId(Long teamId) { - List result = queryFactory.select(teamMember.member.fcmToken) - .from(teamMember) - .where(teamMember.team.teamId.eq(teamId) - .and(teamMember.member.isNewUploadPush.eq(true))) + .and(teamMember.member.memberId.ne(memberId)) + .and(teamMember.isDeleted.eq(false))) .fetch(); return result.isEmpty() ? Optional.empty() : Optional.of(result); diff --git a/src/main/java/com/moing/backend/domain/teamMember/domain/service/TeamMemberGetService.java b/src/main/java/com/moing/backend/domain/teamMember/domain/service/TeamMemberGetService.java index 138d8d0f..2b9dfee2 100644 --- a/src/main/java/com/moing/backend/domain/teamMember/domain/service/TeamMemberGetService.java +++ b/src/main/java/com/moing/backend/domain/teamMember/domain/service/TeamMemberGetService.java @@ -29,10 +29,6 @@ public Optional> getFcmTokensExceptMe(Long teamId, Long memberId) { return teamMemberRepository.findFcmTokensByTeamIdAndMemberId(teamId, memberId); } - public Optional> getFcmTokens(Long teamId) { - return teamMemberRepository.findFcmTokensByTeamId(teamId); - } - public List getTeamMemberInfo(Long teamId){ return teamMemberRepository.findTeamMemberInfoByTeamId(teamId); } From 1c16c6af617d37ac0ec2a47189ee288e04be0cb8 Mon Sep 17 00:00:00 2001 From: minsu20 Date: Mon, 4 Dec 2023 19:18:20 +0900 Subject: [PATCH 2/2] =?UTF-8?q?refactor:=20fcmService=20=EC=9D=98=EC=A1=B4?= =?UTF-8?q?=EC=84=B1=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/SendMissionCreateAlarmUseCase.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/moing/backend/domain/mission/application/service/SendMissionCreateAlarmUseCase.java b/src/main/java/com/moing/backend/domain/mission/application/service/SendMissionCreateAlarmUseCase.java index 3edc96e8..b0a82df3 100644 --- a/src/main/java/com/moing/backend/domain/mission/application/service/SendMissionCreateAlarmUseCase.java +++ b/src/main/java/com/moing/backend/domain/mission/application/service/SendMissionCreateAlarmUseCase.java @@ -5,13 +5,16 @@ import com.moing.backend.domain.mission.domain.entity.Mission; import com.moing.backend.domain.team.domain.entity.Team; import com.moing.backend.domain.teamMember.domain.service.TeamMemberGetService; +import com.moing.backend.global.config.fcm.dto.event.FcmEvent; import com.moing.backend.global.config.fcm.dto.request.MultiRequest; import com.moing.backend.global.config.fcm.service.FcmService; import com.moing.backend.global.response.BaseServiceResponse; import lombok.RequiredArgsConstructor; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; import javax.transaction.Transactional; +import java.util.EventListener; import java.util.List; import java.util.Optional; @@ -24,20 +27,16 @@ public class SendMissionCreateAlarmUseCase { private final TeamMemberGetService teamMemberGetService; - private final FcmService fcmService; + private final ApplicationEventPublisher eventPublisher; public void sendNewMissionUploadAlarm(Member member, Mission mission) { Team team = mission.getTeam(); - Optional> fcmTokensExceptMe = teamMemberGetService.getFcmTokensExceptMe(team.getTeamId(), member.getMemberId()); - String title = team.getName() + " " + NEW_SINGLE_MISSION_COMING.getTitle(); String message = mission.getTitle(); Optional> fcmTokens = teamMemberGetService.getFcmTokensExceptMe(team.getTeamId(), member.getMemberId()); if (fcmTokens.isPresent() && !fcmTokens.get().isEmpty()) { - MultiRequest toMultiRequest = new MultiRequest(fcmTokens.get(), title, message); - fcmService.sendMultipleDevices(toMultiRequest); - + eventPublisher.publishEvent(new FcmEvent(title, message, fcmTokens.get())); } } }