Skip to content

Commit 5a96f53

Browse files
committed
🧩 :: NotificationsListDTO
1 parent 43ecf3b commit 5a96f53

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import Foundation
2+
import Domain
3+
4+
struct NotificationListResponseDTO: Codable {
5+
let notifications: [NotificationResponseDTO]
6+
}
7+
8+
public struct NotificationResponseDTO: Codable {
9+
public let notificationID: Int
10+
public let title, content, topic: String
11+
public let detailID: Int
12+
public let createdAt: String
13+
public let new: Bool
14+
15+
enum CodingKeys: String, CodingKey {
16+
case notificationID = "notification_id"
17+
case title, content, topic
18+
case detailID = "detail_id"
19+
case createdAt = "created_at"
20+
case new
21+
}
22+
}
23+
24+
extension NotificationListResponseDTO {
25+
func toDomain() -> [NotificationEntity] {
26+
notifications.map {
27+
NotificationEntity(
28+
notificationID: $0.notificationID,
29+
title: $0.title,
30+
content: $0.content,
31+
topic: $0.topic,
32+
detailID: $0.detailID,
33+
createdAt: $0.createdAt.toJobisDate().toStringFormat("yyyy.MM.dd"),
34+
new: $0.new
35+
)
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)