mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 10:42:57 +00:00
90 lines
3.5 KiB
Go
90 lines
3.5 KiB
Go
package models
|
|
|
|
import "time"
|
|
|
|
// ManualCompetition stores manually maintained competition metadata for manual club data mode.
|
|
// It is scoped to the primary club (club_id/club_type from Settings) and mirrors key FACR fields.
|
|
type ManualCompetition struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
|
|
// Linkage to main club
|
|
ClubID string `gorm:"index;not null" json:"club_id"` // UUID from fotbal.cz club link
|
|
ClubType string `gorm:"index;not null" json:"club_type"` // football|futsal
|
|
|
|
// FACR-like identifiers and links entered manually
|
|
Code string `gorm:"index;not null" json:"code"` // Competition code, e.g. A1A
|
|
Name string `gorm:"not null" json:"name"` // Display name, e.g. SATUM 5. liga mužů
|
|
ExternalID string `gorm:"index;not null" json:"external_id"` // UUID from soutez/table link
|
|
|
|
MatchesLink string `json:"matches_link"` // e.g. https://www.fotbal.cz/souteze/turnaje/hlavni/<uuid>
|
|
TableLink string `json:"table_link"` // e.g. https://www.fotbal.cz/souteze/turnaje/table/<uuid>
|
|
|
|
TeamCount string `json:"team_count"` // Optional; free-form number as string
|
|
}
|
|
|
|
func (ManualCompetition) TableName() string { return "manual_competitions" }
|
|
|
|
// ManualMatch stores manually entered matches for a competition in manual mode.
|
|
// It is designed so the backend can reconstruct the FACR Match JSON shape.
|
|
type ManualMatch struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
|
|
CompetitionID uint `gorm:"index;not null" json:"competition_id"`
|
|
Competition *ManualCompetition `gorm:"foreignKey:CompetitionID" json:"-"`
|
|
|
|
// Stable identifier parsed from the match link (UUID from fotbal.cz)
|
|
ExternalMatchID string `gorm:"uniqueIndex;not null" json:"external_match_id"`
|
|
|
|
// Round label, e.g. "2. kolo"
|
|
Round string `json:"round"`
|
|
|
|
// Whether the primary club plays at home. If false, the primary club is away.
|
|
IsHome bool `json:"is_home"`
|
|
|
|
// Opponent information (name + fotbal.cz link & ID)
|
|
OpponentName string `json:"opponent_name"`
|
|
OpponentExternalID string `gorm:"index" json:"opponent_external_id"` // UUID from opponent club link
|
|
OpponentURL string `json:"opponent_url"`
|
|
|
|
// Kickoff datetime in local time
|
|
Kickoff time.Time `json:"kickoff"`
|
|
|
|
// Scores as free-form strings (e.g. "2:1", "2:1 (1:0)")
|
|
Score string `json:"score"`
|
|
HalftimeScore string `json:"halftime_score"`
|
|
|
|
// Match link (report URL) and location
|
|
MatchURL string `json:"match_url"`
|
|
Venue string `json:"venue"`
|
|
|
|
// Optional notes
|
|
Note string `json:"note"`
|
|
}
|
|
|
|
func (ManualMatch) TableName() string { return "manual_matches" }
|
|
|
|
// ManualTableRow stores a single row in a competition table (standings) for manual mode.
|
|
type ManualTableRow struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
|
|
CompetitionID uint `gorm:"index;not null" json:"competition_id"`
|
|
Competition *ManualCompetition `gorm:"foreignKey:CompetitionID" json:"-"`
|
|
|
|
// Position, e.g. "1.", "2."
|
|
Rank string `json:"rank"`
|
|
|
|
// Club identification: name and fotbal.cz UUID for logo matching
|
|
TeamName string `json:"team_name"`
|
|
ExternalTeamID string `gorm:"index" json:"external_team_id"`
|
|
|
|
// Basic stats; kept as strings to match FACR JSON and allow flexible input
|
|
Played string `json:"played"` // Z
|
|
Wins string `json:"wins"` // V
|
|
Draws string `json:"draws"` // R
|
|
Losses string `json:"losses"` // P
|
|
Score string `json:"score"` // Skóre, e.g. "45:17"
|
|
Points string `json:"points"` // B
|
|
}
|
|
|
|
func (ManualTableRow) TableName() string { return "manual_table_rows" }
|