Skip to content

Commit

Permalink
feat: paging
Browse files Browse the repository at this point in the history
  • Loading branch information
rlaisqls committed Jul 8, 2023
1 parent 2d8d4ed commit 450b83a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package team.aliens.dms.domain.notification.service

import java.util.UUID
import team.aliens.dms.common.dto.PageData
import team.aliens.dms.domain.notification.model.DeviceToken
import team.aliens.dms.domain.notification.model.NotificationOfUser
import team.aliens.dms.domain.notification.model.TopicSubscription
import java.util.UUID

interface GetNotificationService {

fun getNotificationOfUsersByUserId(userId: UUID): List<NotificationOfUser>
fun getNotificationOfUsersByUserId(userId: UUID, pageData: PageData): List<NotificationOfUser>

fun getTopicSubscriptionsByToken(token: String): List<TopicSubscription>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import team.aliens.dms.domain.notification.spi.QueryDeviceTokenPort
import team.aliens.dms.domain.notification.spi.QueryNotificationOfUserPort
import team.aliens.dms.domain.notification.spi.QueryTopicSubscriptionPort
import java.util.UUID
import team.aliens.dms.common.dto.PageData

@Service
class GetNotificationServiceImpl(
Expand All @@ -15,8 +16,8 @@ class GetNotificationServiceImpl(
private val topicSubscriptionPort: QueryTopicSubscriptionPort
) : GetNotificationService {

override fun getNotificationOfUsersByUserId(userId: UUID) =
notificationOfUserPort.queryNotificationOfUserByUserId(userId)
override fun getNotificationOfUsersByUserId(userId: UUID, pageData: PageData) =
notificationOfUserPort.queryNotificationOfUserByUserId(userId, pageData)

override fun getTopicSubscriptionsByToken(token: String): List<TopicSubscription> {
val savedToken = getDeviceTokenByToken(token)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package team.aliens.dms.domain.notification.spi

import team.aliens.dms.domain.notification.model.NotificationOfUser
import java.util.UUID
import team.aliens.dms.common.dto.PageData
import team.aliens.dms.domain.notification.model.NotificationOfUser

interface QueryNotificationOfUserPort {

fun queryNotificationOfUserByUserId(userId: UUID): List<NotificationOfUser>
fun queryNotificationOfUserByUserId(userId: UUID, pageData: PageData): List<NotificationOfUser>

fun queryNotificationOfUserById(notificationOfUserId: UUID): NotificationOfUser?
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package team.aliens.dms.domain.notification.usecase

import team.aliens.dms.common.annotation.ReadOnlyUseCase
import team.aliens.dms.common.dto.PageData
import team.aliens.dms.domain.notification.dto.NotificationsResponse
import team.aliens.dms.domain.notification.service.NotificationService
import team.aliens.dms.domain.user.service.UserService
Expand All @@ -11,10 +12,10 @@ class QueryMyNotificationsUseCase(
private val notificationService: NotificationService
) {

fun execute(): NotificationsResponse {
fun execute(pageData: PageData): NotificationsResponse {
val user = userService.getCurrentUser()
return NotificationsResponse.of(
notificationService.getNotificationOfUsersByUserId(user.id)
notificationService.getNotificationOfUsersByUserId(user.id, pageData)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class NotificationOfPersistenceAdapterOfUser(
)
}


override fun queryNotificationOfUserByUserId(userId: UUID, pageData: PageData) =
queryFactory
.selectFrom(notificationOfUserJpaEntity)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package team.aliens.dms.domain.notification

import java.util.UUID
import javax.validation.Valid
import org.springframework.http.HttpStatus
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.DeleteMapping
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.ModelAttribute
import org.springframework.web.bind.annotation.PatchMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.ResponseStatus
import org.springframework.web.bind.annotation.RestController
import team.aliens.dms.common.dto.PageData
import team.aliens.dms.domain.notification.dto.NotificationsResponse
import team.aliens.dms.domain.notification.dto.SetDeviceTokenRequest
import team.aliens.dms.domain.notification.dto.TopicSubscriptionGroupsResponse
Expand All @@ -25,8 +29,6 @@ import team.aliens.dms.domain.notification.usecase.SetDeviceTokenUseCase
import team.aliens.dms.domain.notification.usecase.SubscribeTopicUseCase
import team.aliens.dms.domain.notification.usecase.UnsubscribeTopicUseCase
import team.aliens.dms.domain.notification.usecase.UpdateTopicSubscriptionsUseCase
import java.util.UUID
import javax.validation.Valid

@Validated
@RequestMapping("/notifications")
Expand All @@ -50,8 +52,8 @@ class NotificationWebAdapter(
}

@GetMapping
fun queryMyNotifications(): NotificationsResponse {
return queryMyNotificationsUseCase.execute()
fun queryMyNotifications(@ModelAttribute pageData: PageData): NotificationsResponse {
return queryMyNotificationsUseCase.execute(pageData)
}

@PostMapping("/topic")
Expand Down

0 comments on commit 450b83a

Please sign in to comment.