-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: 코드 정리 * test: 리팩토링에 따른 테스트 코드 변경
- Loading branch information
Showing
8 changed files
with
37 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 7 additions & 27 deletions
34
src/main/kotlin/com/depromeet/makers/domain/usecase/GetRecentNotification.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,28 @@ | ||
package com.depromeet.makers.domain.usecase | ||
|
||
import com.depromeet.makers.domain.gateway.NotificationGateway | ||
import com.depromeet.makers.domain.model.Notification | ||
import com.depromeet.makers.domain.model.NotificationType | ||
import java.time.LocalDateTime | ||
|
||
class GetRecentNotification( | ||
private val notificationGateway: NotificationGateway, | ||
) : UseCase<GetRecentNotification.GetRecentNotificationInput, GetRecentNotification.GetRecentNotificationOutput> { | ||
) : UseCase<GetRecentNotification.GetRecentNotificationInput, Notification> { | ||
|
||
data class GetRecentNotificationInput( | ||
val memberId: String, | ||
) | ||
|
||
data class GetRecentNotificationOutput( | ||
val id: String, | ||
val memberId: String, | ||
val content: String, | ||
val type: NotificationType, | ||
val createdAt: LocalDateTime, | ||
val isRead: Boolean = false, | ||
) | ||
|
||
override fun execute(input: GetRecentNotificationInput): GetRecentNotificationOutput { | ||
val notification = notificationGateway.findRecentNotificationByMemberId(input.memberId) | ||
|
||
// 조회 알림이 없다면 default 값 | ||
if (notification == null) { | ||
return GetRecentNotificationOutput( | ||
override fun execute(input: GetRecentNotificationInput): Notification { | ||
// 조회 알림이 없다면 default 값으로 반환 | ||
return notificationGateway.findRecentNotificationByMemberId(input.memberId) | ||
?: return Notification( | ||
id = "defaultId", | ||
memberId = input.memberId, | ||
content = "defaultContent", | ||
type = NotificationType.NONE, | ||
createdAt = LocalDateTime.now(), | ||
isRead = true, | ||
readAt = LocalDateTime.now(), | ||
) | ||
} | ||
|
||
return GetRecentNotificationOutput( | ||
id = notification.id, | ||
memberId = notification.memberId, | ||
content = notification.content, | ||
type = notification.type, | ||
createdAt = notification.createdAt, | ||
isRead = notification.readAt != null, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters