diff --git a/idle-application/src/main/kotlin/com/swm/idle/application/applys/facade/CarerApplyFacadeService.kt b/idle-application/src/main/kotlin/com/swm/idle/application/applys/facade/CarerApplyFacadeService.kt index 6af2e8ba..fc2b120a 100644 --- a/idle-application/src/main/kotlin/com/swm/idle/application/applys/facade/CarerApplyFacadeService.kt +++ b/idle-application/src/main/kotlin/com/swm/idle/application/applys/facade/CarerApplyFacadeService.kt @@ -59,10 +59,10 @@ class CarerApplyFacadeService( } } - centerManagers?.map { centerManager -> - val deviceToken = deviceTokenService.findByUserId(centerManager.id) + centerManagers?.forEach { centerManager -> + val deviceTokens = deviceTokenService.findAllByUserId(centerManager.id) - if (deviceToken != null) { + deviceTokens?.forEach { deviceToken -> val notificationInfo = CarerApplyNotificationInfo( title = "${carer.name} 님이 공고에 지원하였습니다.", body = createBodyMessage(jobPosting), @@ -85,6 +85,7 @@ class CarerApplyFacadeService( } } } + carerApplyService.create(jobPostingId, carer.id, applyMethodType) } @@ -98,4 +99,5 @@ class CarerApplyFacadeService( "${BirthYear.calculateAge(jobPosting.birthYear)}세 " + jobPosting.gender.value } + } diff --git a/idle-application/src/main/kotlin/com/swm/idle/application/notification/domain/DeviceTokenService.kt b/idle-application/src/main/kotlin/com/swm/idle/application/notification/domain/DeviceTokenService.kt index f4674f3b..749b4ef7 100644 --- a/idle-application/src/main/kotlin/com/swm/idle/application/notification/domain/DeviceTokenService.kt +++ b/idle-application/src/main/kotlin/com/swm/idle/application/notification/domain/DeviceTokenService.kt @@ -17,8 +17,8 @@ class DeviceTokenService( return deviceTokenJpaRepository.findByDeviceToken(deviceToken) } - fun findByUserId(userId: UUID): DeviceToken? { - return deviceTokenJpaRepository.findByUserId(userId) + fun findAllByUserId(userId: UUID): List? { + return deviceTokenJpaRepository.findAllByUserId(userId) } @Transactional diff --git a/idle-domain/src/main/kotlin/com/swm/idle/domain/notification/repository/jpa/DeviceTokenJpaRepository.kt b/idle-domain/src/main/kotlin/com/swm/idle/domain/notification/repository/jpa/DeviceTokenJpaRepository.kt index 7ecba361..f214e53d 100644 --- a/idle-domain/src/main/kotlin/com/swm/idle/domain/notification/repository/jpa/DeviceTokenJpaRepository.kt +++ b/idle-domain/src/main/kotlin/com/swm/idle/domain/notification/repository/jpa/DeviceTokenJpaRepository.kt @@ -14,4 +14,6 @@ interface DeviceTokenJpaRepository : JpaRepository { fun findByUserId(userId: UUID): DeviceToken? + fun findAllByUserId(userId: UUID): List? + }