60 lines
1.8 KiB
Swift
60 lines
1.8 KiB
Swift
import Foundation
|
|
import RealmSwift
|
|
|
|
public final class AudioRecord: Object {
|
|
|
|
@Persisted public var path: String = ""
|
|
@Persisted public var number: String?
|
|
@Persisted public var rawText: String = ""
|
|
@Persisted private var addedDate: TimeInterval = 0
|
|
@Persisted public var duration: TimeInterval = 0
|
|
@Persisted public var event: VehicleEvent?
|
|
|
|
public func isContentEqual(to source: AudioRecord) -> Bool {
|
|
return self == source
|
|
}
|
|
|
|
public convenience init(path: String, number: String?, raw: String, duration: TimeInterval, event: VehicleEvent?) {
|
|
self.init()
|
|
self.path = path
|
|
self.number = number
|
|
self.duration = duration
|
|
self.rawText = raw
|
|
self.event = event
|
|
self.addedDate = Date().timeIntervalSince1970
|
|
}
|
|
|
|
public override static func primaryKey() -> String? {
|
|
return "path"
|
|
}
|
|
|
|
public override class func ignoredProperties() -> [String] {
|
|
return ["id", "identifier", "differenceIdentifier"]
|
|
}
|
|
}
|
|
|
|
extension AudioRecord: DtoConvertible {
|
|
|
|
public var dto: AudioRecordDto {
|
|
|
|
var record = AudioRecordDto(path: path,
|
|
number: number,
|
|
raw: rawText,
|
|
duration: duration,
|
|
event: event?.dto)
|
|
record.addedDate = addedDate
|
|
return record
|
|
}
|
|
|
|
public convenience init(dto: AudioRecordDto) {
|
|
|
|
self.init(path: dto.path,
|
|
number: dto.number,
|
|
raw: dto.rawText,
|
|
duration: dto.duration,
|
|
event: VehicleEvent(dto: dto.event))
|
|
|
|
self.addedDate = dto.addedDate
|
|
}
|
|
}
|