Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Notification 도메인 설계 #94

Merged
merged 5 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: 리뷰 반영
nullable -> find
response 필드명 변경
  • Loading branch information
ddingmin committed Jun 14, 2024
commit 6af8c7e57148b9286ce8bbeaa0337b9ddfa77b00
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import com.depromeet.makers.domain.model.Notification

interface NotificationGateway {
fun save(notification: Notification): Notification
fun getRecentNotification(memberId: String): Notification?
fun findRecentNotification(memberId: String): Notification?
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class GetRecentNotification(
val content: String,
val type: NotificationType,
val createdAt: LocalDateTime,
val float: Boolean = false,
val isRead: Boolean = false,
)

override fun execute(input: GetRecentNotificationInput): GetRecentNotificationOutput {
val notification = notificationGateway.getRecentNotification(input.memberId)
val notification = notificationGateway.findRecentNotification(input.memberId)

// 조회 알림이 없다면 default 값
if (notification == null) {
Expand All @@ -32,7 +32,7 @@ class GetRecentNotification(
content = "defaultContent",
type = NotificationType.NONE,
createdAt = LocalDateTime.now(),
float = false,
isRead = true,
)
}

Expand All @@ -42,7 +42,7 @@ class GetRecentNotification(
content = notification.content,
type = notification.type,
createdAt = notification.createdAt,
float = notification.readAt == null,
isRead = notification.readAt != null,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class NotificationGatewayImpl(
.toDomain()
}

override fun getRecentNotification(memberId: String): Notification? {
override fun findRecentNotification(memberId: String): Notification? {
return jpaNotificationRepository
.findFirstByMemberIdOrderByIdDesc(memberId)
?.toDomain()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ data class NotificationResponse(
val type: NotificationType,

@Schema(description = "읽기 여부")
val float: Boolean,
val isRead: Boolean,
) {
companion object {
fun fromDomain(output: GetRecentNotification.GetRecentNotificationOutput) = NotificationResponse(
id = output.id,
memberId = output.memberId,
content = output.content,
type = output.type,
float = output.float,
isRead = output.isRead,
)
}
}