Skip to content

Commit

Permalink
add: (#261) NotificationQueryUserPort
Browse files Browse the repository at this point in the history
  • Loading branch information
softpeanut committed Dec 30, 2022
1 parent fb798e3 commit 2a3caba
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package team.comit.simtong.domain.notification.spi

import java.util.UUID

/**
*
* Notification Domain에서 User Domain에 관한 Query를 요청하는 NotificationQueryUserPort
*
* @author kimbeomjin
* @date 2022/12/30
* @version 1.1.0
**/
interface NotificationQueryUserPort {

fun queryDeviceTokenByUserId(userId: UUID): String?

fun queryDeviceTokensByUserIds(userIds: List<UUID>): List<String>

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package team.comit.simtong.domain.user.spi

import team.comit.simtong.domain.holiday.spi.HolidayQueryUserPort
import team.comit.simtong.domain.menu.spi.MenuQueryUserPort
import team.comit.simtong.domain.notification.spi.NotificationQueryUserPort
import team.comit.simtong.domain.schedule.spi.ScheduleQueryUserPort

/**
Expand All @@ -12,4 +13,4 @@ import team.comit.simtong.domain.schedule.spi.ScheduleQueryUserPort
* @date 2022/09/18
* @version 1.0.0
**/
interface UserPort : QueryUserPort, CommandUserPort, MenuQueryUserPort, ScheduleQueryUserPort, HolidayQueryUserPort
interface UserPort : QueryUserPort, CommandUserPort, MenuQueryUserPort, ScheduleQueryUserPort, HolidayQueryUserPort, NotificationQueryUserPort
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.springframework.stereotype.Component
import team.comit.simtong.domain.user.model.User
import team.comit.simtong.domain.user.spi.UserPort
import team.comit.simtong.persistence.user.mapper.UserMapper
import team.comit.simtong.persistence.user.repository.DeviceTokenJpaRepository
import team.comit.simtong.persistence.user.repository.UserJpaRepository
import java.util.UUID

Expand All @@ -19,8 +20,9 @@ import java.util.UUID
**/
@Component
class UserPersistenceAdapter(
private val userMapper: UserMapper,
private val userJpaRepository: UserJpaRepository,
private val userMapper: UserMapper
private val deviceTokenRepository: DeviceTokenJpaRepository
) : UserPort {

override fun queryUserById(id: UUID): User? {
Expand Down Expand Up @@ -75,4 +77,13 @@ class UserPersistenceAdapter(
).let { userMapper.toDomain(it)!! }
}

override fun queryDeviceTokenByUserId(userId: UUID): String? {
return deviceTokenRepository.findByUserId(userId)?.token
}

override fun queryDeviceTokensByUserIds(userIds: List<UUID>): List<String> {
return deviceTokenRepository.findAllByUserIdIsIn(userIds).map {
it.token
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ import java.util.*
**/
@Repository
interface DeviceTokenJpaRepository : CrudRepository<DeviceTokenJpaEntity, UUID> {

fun findByUserId(userId: UUID): DeviceTokenJpaEntity?

fun findAllByUserIdIsIn(userIds: List<UUID>): List<DeviceTokenJpaEntity>

}

0 comments on commit 2a3caba

Please sign in to comment.