You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
3.7 KiB
99 lines
3.7 KiB
// Generated by SwiftModelGenerator
|
|
// Do not modify this file manually
|
|
|
|
import Foundation
|
|
import LeStorage
|
|
import SwiftUI
|
|
|
|
@Observable
|
|
class BaseDrawLog: SyncedModelObject, SyncedStorable {
|
|
|
|
static func resourceName() -> String { return "draw-logs" }
|
|
static func tokenExemptedMethods() -> [HTTPMethod] { return [] }
|
|
|
|
var id: String = Store.randomId()
|
|
var tournament: String = ""
|
|
var drawDate: Date = Date()
|
|
var drawSeed: Int = 0
|
|
var drawMatchIndex: Int = 0
|
|
var drawTeamPosition: TeamPosition = TeamPosition.one
|
|
var drawType: DrawType = DrawType.seed
|
|
|
|
init(
|
|
id: String = Store.randomId(),
|
|
tournament: String = "",
|
|
drawDate: Date = Date(),
|
|
drawSeed: Int = 0,
|
|
drawMatchIndex: Int = 0,
|
|
drawTeamPosition: TeamPosition = TeamPosition.one,
|
|
drawType: DrawType = DrawType.seed
|
|
) {
|
|
super.init()
|
|
self.id = id
|
|
self.tournament = tournament
|
|
self.drawDate = drawDate
|
|
self.drawSeed = drawSeed
|
|
self.drawMatchIndex = drawMatchIndex
|
|
self.drawTeamPosition = drawTeamPosition
|
|
self.drawType = drawType
|
|
}
|
|
required public override init() {
|
|
super.init()
|
|
}
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
case _id = "id"
|
|
case _tournament = "tournament"
|
|
case _drawDate = "drawDate"
|
|
case _drawSeed = "drawSeed"
|
|
case _drawMatchIndex = "drawMatchIndex"
|
|
case _drawTeamPosition = "drawTeamPosition"
|
|
case _drawType = "drawType"
|
|
}
|
|
|
|
required init(from decoder: Decoder) throws {
|
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
|
self.id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId()
|
|
self.tournament = try container.decodeIfPresent(String.self, forKey: ._tournament) ?? ""
|
|
self.drawDate = try container.decodeIfPresent(Date.self, forKey: ._drawDate) ?? Date()
|
|
self.drawSeed = try container.decodeIfPresent(Int.self, forKey: ._drawSeed) ?? 0
|
|
self.drawMatchIndex = try container.decodeIfPresent(Int.self, forKey: ._drawMatchIndex) ?? 0
|
|
self.drawTeamPosition = try container.decodeIfPresent(TeamPosition.self, forKey: ._drawTeamPosition) ?? TeamPosition.one
|
|
self.drawType = try container.decodeIfPresent(DrawType.self, forKey: ._drawType) ?? DrawType.seed
|
|
try super.init(from: decoder)
|
|
}
|
|
|
|
override func encode(to encoder: Encoder) throws {
|
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
try container.encode(self.id, forKey: ._id)
|
|
try container.encode(self.tournament, forKey: ._tournament)
|
|
try container.encode(self.drawDate, forKey: ._drawDate)
|
|
try container.encode(self.drawSeed, forKey: ._drawSeed)
|
|
try container.encode(self.drawMatchIndex, forKey: ._drawMatchIndex)
|
|
try container.encode(self.drawTeamPosition, forKey: ._drawTeamPosition)
|
|
try container.encode(self.drawType, forKey: ._drawType)
|
|
try super.encode(to: encoder)
|
|
}
|
|
|
|
func tournamentValue() -> Tournament? {
|
|
return Store.main.findById(tournament)
|
|
}
|
|
|
|
func copy(from other: any Storable) {
|
|
guard let drawlog = other as? BaseDrawLog else { return }
|
|
self.id = drawlog.id
|
|
self.tournament = drawlog.tournament
|
|
self.drawDate = drawlog.drawDate
|
|
self.drawSeed = drawlog.drawSeed
|
|
self.drawMatchIndex = drawlog.drawMatchIndex
|
|
self.drawTeamPosition = drawlog.drawTeamPosition
|
|
self.drawType = drawlog.drawType
|
|
}
|
|
|
|
static func relationships() -> [Relationship] {
|
|
return [
|
|
Relationship(type: Tournament.self, keyPath: \BaseDrawLog.tournament),
|
|
]
|
|
}
|
|
|
|
} |