50 lines
1.4 KiB
Swift
50 lines
1.4 KiB
Swift
import Foundation
|
|
import RealmSwift
|
|
|
|
public final class VehicleAd: Object {
|
|
|
|
@Persisted public var id: Int = 0
|
|
@Persisted public var url: String?
|
|
@Persisted public var price: String?
|
|
@Persisted public var date: TimeInterval = Date().timeIntervalSince1970
|
|
@Persisted public var mileage: String?
|
|
@Persisted public var region: String?
|
|
@Persisted public var city: String?
|
|
@Persisted public var adDescription: String?
|
|
@Persisted public var photos: List<String>
|
|
}
|
|
|
|
extension VehicleAd: DtoConvertible {
|
|
|
|
public var dto: VehicleAdDto {
|
|
|
|
VehicleAdDto(id: id,
|
|
url: url,
|
|
price: price,
|
|
date: date,
|
|
mileage: mileage,
|
|
region: region,
|
|
city: city,
|
|
adDescription: adDescription,
|
|
photos: Array(photos))
|
|
}
|
|
|
|
public convenience init(dto: VehicleAdDto) {
|
|
|
|
self.init()
|
|
|
|
self.id = dto.id
|
|
self.url = dto.url
|
|
self.price = dto.price
|
|
self.date = dto.date
|
|
self.mileage = dto.mileage
|
|
self.region = dto.region
|
|
self.city = dto.city
|
|
self.adDescription = dto.adDescription
|
|
|
|
let photos = List<String>()
|
|
photos.append(objectsIn: dto.photos)
|
|
self.photos = photos
|
|
}
|
|
}
|