AutoCat/AutoCatCore/Models/Realm/DebugInfo.swift

61 lines
1.7 KiB
Swift

import Foundation
import RealmSwift
public final class DebugInfo: Object {
@Persisted public var autocod: DebugInfoEntry?
@Persisted public var vin01vin: DebugInfoEntry?
@Persisted public var vin01base: DebugInfoEntry?
@Persisted public var vin01history: DebugInfoEntry?
@Persisted public var nomerogram: DebugInfoEntry?
}
extension DebugInfo: DtoConvertible {
public var dto: DebugInfoDto {
DebugInfoDto(autocod: autocod?.dto,
vin01vin: vin01vin?.dto,
vin01base: vin01base?.dto,
vin01history: vin01history?.dto,
nomerogram: nomerogram?.dto)
}
public convenience init(dto: DebugInfoDto) {
self.init()
autocod = DebugInfoEntry(dto: dto.autocod)
vin01vin = DebugInfoEntry(dto: dto.vin01vin)
vin01base = DebugInfoEntry(dto: dto.vin01base)
vin01history = DebugInfoEntry(dto: dto.vin01history)
nomerogram = DebugInfoEntry(dto: dto.nomerogram)
}
}
public final class DebugInfoEntry: Object, Decodable {
@Persisted public var fields: Int64 = 0
@Persisted public var error: String?
@Persisted public var status: Int = 0
}
extension DebugInfoEntry: DtoConvertible {
public var dto: DebugInfoEntryDto {
DebugInfoEntryDto(fields: fields,
error: error,
status: DebugInfoStatus(rawValue: status) ?? .success)
}
public convenience init(dto: DebugInfoEntryDto) {
self.init()
fields = dto.fields
error = dto.error
status = dto.status.rawValue
}
}