From 4037dd961774b594daa2d1d499fb8ab9888f3ad0 Mon Sep 17 00:00:00 2001 From: Selim Mustafaev Date: Tue, 10 Jun 2025 17:34:27 +0300 Subject: [PATCH] Adding SwiftData models --- AutoCat.xcodeproj/project.pbxproj | 60 +++++++++ .../Models/SwiftData/SDAudioRecord.swift | 41 ++++++ .../Models/SwiftData/SDDebugInfo.swift | 47 +++++++ AutoCatCore/Models/SwiftData/SDOsago.swift | 52 ++++++++ AutoCatCore/Models/SwiftData/SDVehicle.swift | 118 ++++++++++++++++++ .../Models/SwiftData/SDVehicleAd.swift | 46 +++++++ .../Models/SwiftData/SDVehicleBrand.swift | 22 ++++ .../Models/SwiftData/SDVehicleEngine.swift | 33 +++++ .../Models/SwiftData/SDVehicleEvent.swift | 39 ++++++ .../Models/SwiftData/SDVehicleModel.swift | 20 +++ .../Models/SwiftData/SDVehicleName.swift | 21 ++++ .../Models/SwiftData/SDVehicleNote.swift | 33 +++++ .../SwiftData/SDVehicleOwnershipPeriod.swift | 51 ++++++++ .../Models/SwiftData/SDVehiclePhoto.swift | 31 +++++ 14 files changed, 614 insertions(+) create mode 100644 AutoCatCore/Models/SwiftData/SDAudioRecord.swift create mode 100644 AutoCatCore/Models/SwiftData/SDDebugInfo.swift create mode 100644 AutoCatCore/Models/SwiftData/SDOsago.swift create mode 100644 AutoCatCore/Models/SwiftData/SDVehicle.swift create mode 100644 AutoCatCore/Models/SwiftData/SDVehicleAd.swift create mode 100644 AutoCatCore/Models/SwiftData/SDVehicleBrand.swift create mode 100644 AutoCatCore/Models/SwiftData/SDVehicleEngine.swift create mode 100644 AutoCatCore/Models/SwiftData/SDVehicleEvent.swift create mode 100644 AutoCatCore/Models/SwiftData/SDVehicleModel.swift create mode 100644 AutoCatCore/Models/SwiftData/SDVehicleName.swift create mode 100644 AutoCatCore/Models/SwiftData/SDVehicleNote.swift create mode 100644 AutoCatCore/Models/SwiftData/SDVehicleOwnershipPeriod.swift create mode 100644 AutoCatCore/Models/SwiftData/SDVehiclePhoto.swift diff --git a/AutoCat.xcodeproj/project.pbxproj b/AutoCat.xcodeproj/project.pbxproj index 637943e..7bcccd8 100644 --- a/AutoCat.xcodeproj/project.pbxproj +++ b/AutoCat.xcodeproj/project.pbxproj @@ -11,6 +11,12 @@ 7A06E0AE2C7065C7005731AC /* SettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A06E0AD2C7065C7005731AC /* SettingsViewModel.swift */; }; 7A06E0B32C707E13005731AC /* SettingsServiceProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A06E0B22C707E13005731AC /* SettingsServiceProtocol.swift */; }; 7A06E0B52C707E2B005731AC /* SettingsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A06E0B42C707E2B005731AC /* SettingsService.swift */; }; + 7A0818722DF83CF0000219FE /* SDVehicle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A0818712DF83CF0000219FE /* SDVehicle.swift */; }; + 7A0818742DF83D98000219FE /* SDVehicleBrand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A0818732DF83D98000219FE /* SDVehicleBrand.swift */; }; + 7A0818762DF83DB4000219FE /* SDVehicleName.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A0818752DF83DB4000219FE /* SDVehicleName.swift */; }; + 7A0818782DF84AE4000219FE /* SDVehicleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A0818772DF84AE4000219FE /* SDVehicleModel.swift */; }; + 7A08187A2DF84B77000219FE /* SDVehicleEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A0818792DF84B77000219FE /* SDVehicleEngine.swift */; }; + 7A08187E2DF84CE0000219FE /* SDVehiclePhoto.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A08187D2DF84CE0000219FE /* SDVehiclePhoto.swift */; }; 7A10226C2C551EC500B84627 /* LocationEditScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A10226B2C551EC500B84627 /* LocationEditScreen.swift */; }; 7A10226E2C551EE000B84627 /* LocationEditViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A10226D2C551EE000B84627 /* LocationEditViewModel.swift */; }; 7A1022772C557EC400B84627 /* LocationPickerScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A1022762C557EC400B84627 /* LocationPickerScreen.swift */; }; @@ -154,6 +160,13 @@ 7ACBB91E2CB9B155005A5168 /* Mockable in Frameworks */ = {isa = PBXBuildFile; productRef = 7ACBB91D2CB9B155005A5168 /* Mockable */; }; 7ACBB9202CB9B16C005A5168 /* Mockable in Frameworks */ = {isa = PBXBuildFile; productRef = 7ACBB91F2CB9B16C005A5168 /* Mockable */; }; 7AD176B02DC127540023049D /* PNButtonType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AD176AF2DC127540023049D /* PNButtonType.swift */; }; + 7AD8571E2DF8700F009E4B72 /* SDVehicleOwnershipPeriod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AD8571D2DF8700F009E4B72 /* SDVehicleOwnershipPeriod.swift */; }; + 7AD857202DF874F8009E4B72 /* SDVehicleEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AD8571F2DF874F8009E4B72 /* SDVehicleEvent.swift */; }; + 7AD857222DF875B2009E4B72 /* SDOsago.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AD857212DF875B2009E4B72 /* SDOsago.swift */; }; + 7AD857242DF87637009E4B72 /* SDVehicleAd.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AD857232DF87637009E4B72 /* SDVehicleAd.swift */; }; + 7AD857262DF876C9009E4B72 /* SDVehicleNote.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AD857252DF876C9009E4B72 /* SDVehicleNote.swift */; }; + 7AD857282DF87733009E4B72 /* SDDebugInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AD857272DF87733009E4B72 /* SDDebugInfo.swift */; }; + 7AD8572A2DF87928009E4B72 /* SDAudioRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AD857292DF87928009E4B72 /* SDAudioRecord.swift */; }; 7ADCBC572DB51739002522C0 /* AutoCatApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ADCBC562DB51739002522C0 /* AutoCatApp.swift */; }; 7ADF6C99250F872C00F237B2 /* RoadNumbers.otf in Resources */ = {isa = PBXBuildFile; fileRef = 7ADF6C98250F872C00F237B2 /* RoadNumbers.otf */; }; 7ADF6CA12512244400F237B2 /* MapExt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ADF6CA02512244400F237B2 /* MapExt.swift */; }; @@ -252,6 +265,12 @@ 7A06E0AD2C7065C7005731AC /* SettingsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewModel.swift; sourceTree = ""; }; 7A06E0B22C707E13005731AC /* SettingsServiceProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsServiceProtocol.swift; sourceTree = ""; }; 7A06E0B42C707E2B005731AC /* SettingsService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsService.swift; sourceTree = ""; }; + 7A0818712DF83CF0000219FE /* SDVehicle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDVehicle.swift; sourceTree = ""; }; + 7A0818732DF83D98000219FE /* SDVehicleBrand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDVehicleBrand.swift; sourceTree = ""; }; + 7A0818752DF83DB4000219FE /* SDVehicleName.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDVehicleName.swift; sourceTree = ""; }; + 7A0818772DF84AE4000219FE /* SDVehicleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDVehicleModel.swift; sourceTree = ""; }; + 7A0818792DF84B77000219FE /* SDVehicleEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDVehicleEngine.swift; sourceTree = ""; }; + 7A08187D2DF84CE0000219FE /* SDVehiclePhoto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDVehiclePhoto.swift; sourceTree = ""; }; 7A10226B2C551EC500B84627 /* LocationEditScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationEditScreen.swift; sourceTree = ""; }; 7A10226D2C551EE000B84627 /* LocationEditViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationEditViewModel.swift; sourceTree = ""; }; 7A1022762C557EC400B84627 /* LocationPickerScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationPickerScreen.swift; sourceTree = ""; }; @@ -406,6 +425,13 @@ 7AC44B812DB390B900ADC026 /* MainTabScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainTabScreen.swift; sourceTree = ""; }; 7AC8B2752D6A01C700190706 /* UISearchTextField+Dumb.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UISearchTextField+Dumb.swift"; sourceTree = ""; }; 7AD176AF2DC127540023049D /* PNButtonType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PNButtonType.swift; sourceTree = ""; }; + 7AD8571D2DF8700F009E4B72 /* SDVehicleOwnershipPeriod.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDVehicleOwnershipPeriod.swift; sourceTree = ""; }; + 7AD8571F2DF874F8009E4B72 /* SDVehicleEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDVehicleEvent.swift; sourceTree = ""; }; + 7AD857212DF875B2009E4B72 /* SDOsago.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDOsago.swift; sourceTree = ""; }; + 7AD857232DF87637009E4B72 /* SDVehicleAd.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDVehicleAd.swift; sourceTree = ""; }; + 7AD857252DF876C9009E4B72 /* SDVehicleNote.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDVehicleNote.swift; sourceTree = ""; }; + 7AD857272DF87733009E4B72 /* SDDebugInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDDebugInfo.swift; sourceTree = ""; }; + 7AD857292DF87928009E4B72 /* SDAudioRecord.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDAudioRecord.swift; sourceTree = ""; }; 7ADCBC562DB51739002522C0 /* AutoCatApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoCatApp.swift; sourceTree = ""; }; 7ADF6C98250F872C00F237B2 /* RoadNumbers.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = RoadNumbers.otf; sourceTree = ""; }; 7ADF6CA02512244400F237B2 /* MapExt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapExt.swift; sourceTree = ""; }; @@ -515,6 +541,26 @@ path = SettingsService; sourceTree = ""; }; + 7A0818702DF82B8C000219FE /* SwiftData */ = { + isa = PBXGroup; + children = ( + 7A0818712DF83CF0000219FE /* SDVehicle.swift */, + 7A0818732DF83D98000219FE /* SDVehicleBrand.swift */, + 7A0818752DF83DB4000219FE /* SDVehicleName.swift */, + 7A0818772DF84AE4000219FE /* SDVehicleModel.swift */, + 7A0818792DF84B77000219FE /* SDVehicleEngine.swift */, + 7A08187D2DF84CE0000219FE /* SDVehiclePhoto.swift */, + 7AD8571D2DF8700F009E4B72 /* SDVehicleOwnershipPeriod.swift */, + 7AD8571F2DF874F8009E4B72 /* SDVehicleEvent.swift */, + 7AD857212DF875B2009E4B72 /* SDOsago.swift */, + 7AD857232DF87637009E4B72 /* SDVehicleAd.swift */, + 7AD857252DF876C9009E4B72 /* SDVehicleNote.swift */, + 7AD857272DF87733009E4B72 /* SDDebugInfo.swift */, + 7AD857292DF87928009E4B72 /* SDAudioRecord.swift */, + ); + path = SwiftData; + sourceTree = ""; + }; 7A10226A2C551EA200B84627 /* LocationEditScreen */ = { isa = PBXGroup; children = ( @@ -589,6 +635,7 @@ 7A11474523FF2A9000B424AF /* Models */ = { isa = PBXGroup; children = ( + 7A0818702DF82B8C000219FE /* SwiftData */, 7A5D84BA2C1AD80400C2209B /* Realm */, 7A64A2042C19DA2D00284124 /* Protocols */, 7A64A2012C19D99D00284124 /* DTO */, @@ -1426,6 +1473,7 @@ 7ABDA8092D8710F80083C715 /* AutoCancellable.swift in Sources */, 7A5D84C02C1AE4DC00C2209B /* VehicleEngine.swift in Sources */, 7AB0EF812C5CC0FE00291EE6 /* SwiftLocationProtocol.swift in Sources */, + 7AD857242DF87637009E4B72 /* SDVehicleAd.swift in Sources */, 7AF6D2282677C2DC0086EA64 /* Constants.swift in Sources */, 7A64A2182C19E64800284124 /* VehicleOwnershipPeriodDto.swift in Sources */, 7ABDA8052D8705210083C715 /* VehicleRecordServiceProtocol.swift in Sources */, @@ -1440,23 +1488,29 @@ 7A64A2262C1A32C800284124 /* AudioRecordDto.swift in Sources */, 7A761C09267E8EE40005F28F /* Base64FS.swift in Sources */, 7A64A21E2C19E8D500284124 /* VehicleAdDto.swift in Sources */, + 7AD857202DF874F8009E4B72 /* SDVehicleEvent.swift in Sources */, 7AF6D2202677C1680086EA64 /* Filter.swift in Sources */, 7A761C042677F18E0005F28F /* ApiService.swift in Sources */, 7A95197B2D80B41600E69883 /* AudioRecordServiceProtocol.swift in Sources */, 7AF6D21C2677C1680086EA64 /* DebugInfo.swift in Sources */, + 7A0818762DF83DB4000219FE /* SDVehicleName.swift in Sources */, 7ABDA80D2D8721B10083C715 /* Substrings.swift in Sources */, 7A2A8F772DEF205A00FC0AE2 /* VehicleNumberType.swift in Sources */, 7AF6D2142677C1680086EA64 /* VehicleEvent.swift in Sources */, + 7A0818742DF83D98000219FE /* SDVehicleBrand.swift in Sources */, 7A64A2102C19E1EB00284124 /* VehicleBrandDto.swift in Sources */, 7A599C392C18B22900D47C18 /* FbRefreshTokenModel.swift in Sources */, 7AF6D2172677C1680086EA64 /* VehicleRegion.swift in Sources */, 7A6F096026DBF588003A965D /* VehicleNote.swift in Sources */, 7AF6D21E2677C1680086EA64 /* PlateNumber.swift in Sources */, 7A5D84C62C1AE72E00C2209B /* VehicleName.swift in Sources */, + 7AD8572A2DF87928009E4B72 /* SDAudioRecord.swift in Sources */, + 7AD8571E2DF8700F009E4B72 /* SDVehicleOwnershipPeriod.swift in Sources */, 7A64A2122C19E2A100284124 /* VehicleModelDto.swift in Sources */, 7ABDA80B2D8715DC0083C715 /* VehicleRecordError.swift in Sources */, 7A06E0B32C707E13005731AC /* SettingsServiceProtocol.swift in Sources */, 7A06E0B52C707E2B005731AC /* SettingsService.swift in Sources */, + 7AD857282DF87733009E4B72 /* SDDebugInfo.swift in Sources */, 7AF6D21F2677C1680086EA64 /* Response.swift in Sources */, 7AA515D02D9ABCC800EB3418 /* RecordPlayerService.swift in Sources */, 7A60D24D2C5A9D4900D13F7B /* LocationService.swift in Sources */, @@ -1464,22 +1518,28 @@ 7A761C07267E8E7F0005F28F /* AnyEncodable.swift in Sources */, 7A64A2032C19DA1000284124 /* VehicleDto.swift in Sources */, 7AB4E4332D3C21C00006D052 /* FileManagerExt.swift in Sources */, + 7AD857262DF876C9009E4B72 /* SDVehicleNote.swift in Sources */, 7A9519792D80B3E800E69883 /* AudioRecordService.swift in Sources */, 7AB587322C42D38E00FA7B66 /* StorageServiceProtocol.swift in Sources */, + 7A08187E2DF84CE0000219FE /* SDVehiclePhoto.swift in Sources */, 7AB4E43B2D3D3F4F0006D052 /* VehicleServiceProtocol.swift in Sources */, 7AA514E02D0B75B3001CAC50 /* StorageService+Events.swift in Sources */, 7A64A2222C19E99E00284124 /* DebugInfoDto.swift in Sources */, 7A5D84BC2C1AD81000C2209B /* VehicleOwnershipPeriod.swift in Sources */, + 7A0818722DF83CF0000219FE /* SDVehicle.swift in Sources */, 7A64A2202C19E93500284124 /* VehicleNoteDto.swift in Sources */, 7AF6D21A2677C1680086EA64 /* User.swift in Sources */, 7A60D2512C5A9E4200D13F7B /* GeocoderProtocol.swift in Sources */, 7AB4E4382D3D0C5C0006D052 /* VehiclesArchive.swift in Sources */, 7A64A21C2C19E87B00284124 /* OsagoDto.swift in Sources */, 7AA515D22D9ABCE600EB3418 /* RecordPlayerServiceProtocol.swift in Sources */, + 7A0818782DF84AE4000219FE /* SDVehicleModel.swift in Sources */, + 7A08187A2DF84B77000219FE /* SDVehicleEngine.swift in Sources */, 7AA515DA2D9ADEF000EB3418 /* StorageError.swift in Sources */, 7A809F392D66755B00CF1B3C /* Error+Canceled.swift in Sources */, 7AF6D21D2677C1680086EA64 /* Osago.swift in Sources */, 7A1CF81629A42117007962DA /* Realm.swift in Sources */, + 7AD857222DF875B2009E4B72 /* SDOsago.swift in Sources */, 7ABDA80F2D8723F90083C715 /* StorageService+AudioRecords.swift in Sources */, 7A64A2142C19E3B700284124 /* VehicleEngineDto.swift in Sources */, 7A761C052677F1BC0005F28F /* CocoaError.swift in Sources */, diff --git a/AutoCatCore/Models/SwiftData/SDAudioRecord.swift b/AutoCatCore/Models/SwiftData/SDAudioRecord.swift new file mode 100644 index 0000000..967cf14 --- /dev/null +++ b/AutoCatCore/Models/SwiftData/SDAudioRecord.swift @@ -0,0 +1,41 @@ +// +// SDAudioRecord.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 10.06.2025. +// Copyright © 2025 Selim Mustafaev. All rights reserved. +// + +import Foundation +import SwiftData + +@Model +final class SDAudioRecord { + + @Attribute(.unique) + var path: String + + var number: String? + var rawText: String + var addedDate: TimeInterval + var duration: TimeInterval + + @Relationship(deleteRule: .cascade) + var event: SDVehicleEvent? + + init( + path: String, + number: String? = nil, + rawText: String, + addedDate: TimeInterval, + duration: TimeInterval, + event: SDVehicleEvent? = nil + ) { + self.path = path + self.number = number + self.rawText = rawText + self.addedDate = addedDate + self.duration = duration + self.event = event + } +} diff --git a/AutoCatCore/Models/SwiftData/SDDebugInfo.swift b/AutoCatCore/Models/SwiftData/SDDebugInfo.swift new file mode 100644 index 0000000..ffcb6b8 --- /dev/null +++ b/AutoCatCore/Models/SwiftData/SDDebugInfo.swift @@ -0,0 +1,47 @@ +// +// SDDebugInfo.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 10.06.2025. +// Copyright © 2025 Selim Mustafaev. All rights reserved. +// + +import SwiftData + +@Model +final class SDDebugInfo { + + @Relationship(deleteRule: .cascade) var autocod: SDDebugInfoEntry? + @Relationship(deleteRule: .cascade) var vin01vin: SDDebugInfoEntry? + @Relationship(deleteRule: .cascade) var vin01base: SDDebugInfoEntry? + @Relationship(deleteRule: .cascade) var vin01history: SDDebugInfoEntry? + @Relationship(deleteRule: .cascade) var nomerogram: SDDebugInfoEntry? + + init( + autocod: SDDebugInfoEntry? = nil, + vin01vin: SDDebugInfoEntry? = nil, + vin01base: SDDebugInfoEntry? = nil, + vin01history: SDDebugInfoEntry? = nil, + nomerogram: SDDebugInfoEntry? = nil + ) { + self.autocod = autocod + self.vin01vin = vin01vin + self.vin01base = vin01base + self.vin01history = vin01history + self.nomerogram = nomerogram + } +} + +@Model +final class SDDebugInfoEntry { + + var fields: Int64 + var error: String? + var status: Int + + init(fields: Int64, error: String? = nil, status: Int) { + self.fields = fields + self.error = error + self.status = status + } +} diff --git a/AutoCatCore/Models/SwiftData/SDOsago.swift b/AutoCatCore/Models/SwiftData/SDOsago.swift new file mode 100644 index 0000000..b67704f --- /dev/null +++ b/AutoCatCore/Models/SwiftData/SDOsago.swift @@ -0,0 +1,52 @@ +// +// SDOsago.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 10.06.2025. +// Copyright © 2025 Selim Mustafaev. All rights reserved. +// + +import Foundation +import SwiftData + +@Model +final class SDOsago { + + var date: TimeInterval + var number: String + var vin: String? + var plateNumber: String? + var name: String + var status: String? + var restrictions: String + var insurant: String? + var owner: String? + var usageRegion: String? + var birthday: String? + + init( + date: TimeInterval, + number: String, + vin: String? = nil, + plateNumber: String? = nil, + name: String, + status: String? = nil, + restrictions: String, + insurant: String? = nil, + owner: String? = nil, + usageRegion: String? = nil, + birthday: String? = nil + ) { + self.date = date + self.number = number + self.vin = vin + self.plateNumber = plateNumber + self.name = name + self.status = status + self.restrictions = restrictions + self.insurant = insurant + self.owner = owner + self.usageRegion = usageRegion + self.birthday = birthday + } +} diff --git a/AutoCatCore/Models/SwiftData/SDVehicle.swift b/AutoCatCore/Models/SwiftData/SDVehicle.swift new file mode 100644 index 0000000..c138e6f --- /dev/null +++ b/AutoCatCore/Models/SwiftData/SDVehicle.swift @@ -0,0 +1,118 @@ +// +// SDVehicle.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 10.06.2025. +// Copyright © 2025 Selim Mustafaev. All rights reserved. +// + +import Foundation +import SwiftData + +@Model +final class SDVehicle { + + @Relationship(deleteRule: .cascade) + var brand: SDVehicleBrand? + + @Relationship(deleteRule: .cascade) + var model: SDVehicleModel? + + var color: String? + var year: Int + var category: String? + + @Relationship(deleteRule: .cascade) + var engine: SDVehicleEngine? + + @Attribute(.unique) + var number: String + + var currentNumber: String? + var vin1: String? + var vin2: String? + var sts: String? + var pts: String? + var isRightWheel: Bool? + var isJapanese: Bool? + var addedDate: TimeInterval + var updatedDate: TimeInterval + var addedBy: String + + @Relationship(deleteRule: .cascade) + var photos: [SDVehiclePhoto] + + @Relationship(deleteRule: .cascade) + var ownershipPeriods: [SDVehicleOwnershipPeriod] + + @Relationship(deleteRule: .cascade) + var events: [SDVehicleEvent] + + @Relationship(deleteRule: .cascade) + var osagoContracts: [SDOsago] + + @Relationship(deleteRule: .cascade) + var ads: [SDVehicleAd] + + @Relationship(deleteRule: .cascade) + var notes: [SDVehicleNote] + + @Relationship(deleteRule: .cascade) + var debugInfo: SDDebugInfo? + + var synchronized: Bool + + init( + brand: SDVehicleBrand? = nil, + model: SDVehicleModel? = nil, + color: String? = nil, + year: Int, + category: String? = nil, + engine: SDVehicleEngine? = nil, + number: String, + currentNumber: String? = nil, + vin1: String? = nil, + vin2: String? = nil, + sts: String? = nil, + pts: String? = nil, + isRightWheel: Bool? = nil, + isJapanese: Bool? = nil, + addedDate: TimeInterval, + updatedDate: TimeInterval, + addedBy: String, + photos: [SDVehiclePhoto], + ownershipPeriods: [SDVehicleOwnershipPeriod], + events: [SDVehicleEvent], + osagoContracts: [SDOsago], + ads: [SDVehicleAd], + notes: [SDVehicleNote], + debugInfo: SDDebugInfo? = nil, + synchronized: Bool + ) { + self.brand = brand + self.model = model + self.color = color + self.year = year + self.category = category + self.engine = engine + self.number = number + self.currentNumber = currentNumber + self.vin1 = vin1 + self.vin2 = vin2 + self.sts = sts + self.pts = pts + self.isRightWheel = isRightWheel + self.isJapanese = isJapanese + self.addedDate = addedDate + self.updatedDate = updatedDate + self.addedBy = addedBy + self.photos = photos + self.ownershipPeriods = ownershipPeriods + self.events = events + self.osagoContracts = osagoContracts + self.ads = ads + self.notes = notes + self.debugInfo = debugInfo + self.synchronized = synchronized + } +} diff --git a/AutoCatCore/Models/SwiftData/SDVehicleAd.swift b/AutoCatCore/Models/SwiftData/SDVehicleAd.swift new file mode 100644 index 0000000..25a4771 --- /dev/null +++ b/AutoCatCore/Models/SwiftData/SDVehicleAd.swift @@ -0,0 +1,46 @@ +// +// SDVehicleAd.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 10.06.2025. +// Copyright © 2025 Selim Mustafaev. All rights reserved. +// + +import Foundation +import SwiftData + +@Model +final class SDVehicleAd { + + var id: Int + var url: String? + var price: String? + var date: TimeInterval + var mileage: String? + var region: String? + var city: String? + var adDescription: String? + var photos: [String] + + init( + id: Int, + url: String? = nil, + price: String? = nil, + date: TimeInterval, + mileage: String? = nil, + region: String? = nil, + city: String? = nil, + adDescription: String? = nil, + photos: [String] + ) { + self.id = id + self.url = url + self.price = price + self.date = date + self.mileage = mileage + self.region = region + self.city = city + self.adDescription = adDescription + self.photos = photos + } +} diff --git a/AutoCatCore/Models/SwiftData/SDVehicleBrand.swift b/AutoCatCore/Models/SwiftData/SDVehicleBrand.swift new file mode 100644 index 0000000..018cf03 --- /dev/null +++ b/AutoCatCore/Models/SwiftData/SDVehicleBrand.swift @@ -0,0 +1,22 @@ +// +// SDVehicleBrand.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 10.06.2025. +// Copyright © 2025 Selim Mustafaev. All rights reserved. +// + +import SwiftData + +@Model +final class SDVehicleBrand { + + @Relationship(deleteRule: .cascade) + var name: SDVehicleName? + var logo: String? + + init(name: SDVehicleName? = nil, logo: String? = nil) { + self.name = name + self.logo = logo + } +} diff --git a/AutoCatCore/Models/SwiftData/SDVehicleEngine.swift b/AutoCatCore/Models/SwiftData/SDVehicleEngine.swift new file mode 100644 index 0000000..879f3cc --- /dev/null +++ b/AutoCatCore/Models/SwiftData/SDVehicleEngine.swift @@ -0,0 +1,33 @@ +// +// SDVehicleEngine.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 10.06.2025. +// Copyright © 2025 Selim Mustafaev. All rights reserved. +// + +import SwiftData + +@Model +final class SDVehicleEngine { + + var number: String? + var volume: Int? + var powerHp: Float? + var powerKw: Float? + var fuelType: String? + + init( + number: String? = nil, + volume: Int? = nil, + powerHp: Float? = nil, + powerKw: Float? = nil, + fuelType: String? = nil + ) { + self.number = number + self.volume = volume + self.powerHp = powerHp + self.powerKw = powerKw + self.fuelType = fuelType + } +} diff --git a/AutoCatCore/Models/SwiftData/SDVehicleEvent.swift b/AutoCatCore/Models/SwiftData/SDVehicleEvent.swift new file mode 100644 index 0000000..4b7b364 --- /dev/null +++ b/AutoCatCore/Models/SwiftData/SDVehicleEvent.swift @@ -0,0 +1,39 @@ +// +// SDVehicleEvent.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 10.06.2025. +// Copyright © 2025 Selim Mustafaev. All rights reserved. +// + +import Foundation +import SwiftData + +@Model +final class SDVehicleEvent { + + @Attribute(.unique) + var id: String + + var date: TimeInterval + var latitude: Double + var longitude: Double + var address: String? + var addedBy: String? + + init( + id: String, + date: TimeInterval, + latitude: Double, + longitude: Double, + address: String? = nil, + addedBy: String? = nil + ) { + self.id = id + self.date = date + self.latitude = latitude + self.longitude = longitude + self.address = address + self.addedBy = addedBy + } +} diff --git a/AutoCatCore/Models/SwiftData/SDVehicleModel.swift b/AutoCatCore/Models/SwiftData/SDVehicleModel.swift new file mode 100644 index 0000000..8fef1ed --- /dev/null +++ b/AutoCatCore/Models/SwiftData/SDVehicleModel.swift @@ -0,0 +1,20 @@ +// +// SDVehicleModel.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 10.06.2025. +// Copyright © 2025 Selim Mustafaev. All rights reserved. +// + +import SwiftData + +@Model +final class SDVehicleModel { + + @Relationship(deleteRule: .cascade) + var name: SDVehicleName? + + init(name: SDVehicleName? = nil) { + self.name = name + } +} diff --git a/AutoCatCore/Models/SwiftData/SDVehicleName.swift b/AutoCatCore/Models/SwiftData/SDVehicleName.swift new file mode 100644 index 0000000..0f16a28 --- /dev/null +++ b/AutoCatCore/Models/SwiftData/SDVehicleName.swift @@ -0,0 +1,21 @@ +// +// SDVehicleName.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 10.06.2025. +// Copyright © 2025 Selim Mustafaev. All rights reserved. +// + +import SwiftData + +@Model +final class SDVehicleName { + + var original: String? + var normalized: String? + + init(original: String? = nil, normalized: String? = nil) { + self.original = original + self.normalized = normalized + } +} diff --git a/AutoCatCore/Models/SwiftData/SDVehicleNote.swift b/AutoCatCore/Models/SwiftData/SDVehicleNote.swift new file mode 100644 index 0000000..627fb96 --- /dev/null +++ b/AutoCatCore/Models/SwiftData/SDVehicleNote.swift @@ -0,0 +1,33 @@ +// +// SDVehicleNote.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 10.06.2025. +// Copyright © 2025 Selim Mustafaev. All rights reserved. +// + +import Foundation +import SwiftData + +@Model +final class SDVehicleNote { + + @Attribute(.unique) + var id: String + + var user: String + var date: TimeInterval + var text: String + + init( + id: String, + user: String, + date: TimeInterval, + text: String + ) { + self.id = id + self.user = user + self.date = date + self.text = text + } +} diff --git a/AutoCatCore/Models/SwiftData/SDVehicleOwnershipPeriod.swift b/AutoCatCore/Models/SwiftData/SDVehicleOwnershipPeriod.swift new file mode 100644 index 0000000..8546edb --- /dev/null +++ b/AutoCatCore/Models/SwiftData/SDVehicleOwnershipPeriod.swift @@ -0,0 +1,51 @@ +// +// SDVehicleOwnershipPeriod.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 10.06.2025. +// Copyright © 2025 Selim Mustafaev. All rights reserved. +// + +import SwiftData + +@Model +final class SDVehicleOwnershipPeriod { + + var lastOperation: String + var ownerType: String + var from: Int64 + var to: Int64 + var region: String? + var registrationRegion: String? + var locality: String? + var code: String? + var street: String? + var building: String? + var inn: String? + + init( + lastOperation: String, + ownerType: String, + from: Int64, + to: Int64, + region: String? = nil, + registrationRegion: String? = nil, + locality: String? = nil, + code: String? = nil, + street: String? = nil, + building: String? = nil, + inn: String? = nil + ) { + self.lastOperation = lastOperation + self.ownerType = ownerType + self.from = from + self.to = to + self.region = region + self.registrationRegion = registrationRegion + self.locality = locality + self.code = code + self.street = street + self.building = building + self.inn = inn + } +} diff --git a/AutoCatCore/Models/SwiftData/SDVehiclePhoto.swift b/AutoCatCore/Models/SwiftData/SDVehiclePhoto.swift new file mode 100644 index 0000000..cd7c472 --- /dev/null +++ b/AutoCatCore/Models/SwiftData/SDVehiclePhoto.swift @@ -0,0 +1,31 @@ +// +// SDVehiclePhoto.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 10.06.2025. +// Copyright © 2025 Selim Mustafaev. All rights reserved. +// + +import Foundation +import SwiftData + +@Model +final class SDVehiclePhoto { + + var brand: String? + var model: String? + var date: TimeInterval + var url: String + + init( + brand: String? = nil, + model: String? = nil, + date: TimeInterval, + url: String + ) { + self.brand = brand + self.model = model + self.date = date + self.url = url + } +}