-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathReportDTO.swift
More file actions
55 lines (51 loc) · 1.7 KB
/
ReportDTO.swift
File metadata and controls
55 lines (51 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// ReportDTO.swift
// DataSource
//
// Created by 최정인 on 11/20/25.
//
import Domain
struct ReportDTO: Codable {
let reportId: Int?
let reportDate: String?
let reportTitle: String
let reportContent: String?
let reportLocation: String
let reportStatus: String?
let reportCategory: String
let reportImageUrl: String?
let reportImageUrls: [String]?
let latitude: Double?
let longitude: Double?
func toReportEntity() throws -> ReportEntity {
return ReportEntity(
id: reportId,
title: reportTitle,
date: reportDate,
type: ReportType(rawValue: reportCategory) ?? .transportation,
progress: ReportProgress(rawValue: reportStatus ?? "") ?? .received,
content: reportContent,
location: LocationEntity(
longitude: longitude,
latitude: latitude,
address: reportLocation),
thumbnailURL: reportImageUrl,
photoUrls: reportImageUrls ?? [])
}
func toReportEntity(date: String) throws -> ReportEntity {
guard let reportId else { throw NetworkError.decodingError }
return ReportEntity(
id: reportId,
title: reportTitle,
date: date,
type: ReportType(rawValue: reportCategory) ?? .transportation,
progress: ReportProgress(rawValue: reportStatus ?? "") ?? .received,
content: reportContent,
location: LocationEntity(
longitude: longitude,
latitude: latitude,
address: reportLocation),
thumbnailURL: reportImageUrl,
photoUrls: reportImageUrls ?? [])
}
}