generated from schreifuchs/wails-template
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package model
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Game struct {
|
|
gorm.Model
|
|
Name string
|
|
}
|
|
|
|
type Participant struct {
|
|
gorm.Model
|
|
Name string
|
|
IsTemporary bool `json:"Size,string,omitempty"` // only for one tournament
|
|
IsTeam bool
|
|
Tournaments []*Tournament `gorm:"many2many:partcipant_tournaments;"`
|
|
}
|
|
|
|
type Tournament struct {
|
|
gorm.Model
|
|
Title string
|
|
GameID int
|
|
Game Game `gorm:"foreignKey:GameID"`
|
|
Size int // number of prarticipants
|
|
TournamentState int
|
|
WinnerParticipantID int
|
|
WinnerParticipant Participant `gorm:"foreignKey:WinnerParticipantID"`
|
|
Participants []*Participant `gorm:"many2many:partcipant_tournaments;"`
|
|
Matches []Match
|
|
}
|
|
|
|
type Match struct {
|
|
gorm.Model
|
|
TournamentID uint
|
|
Stage int
|
|
Order int
|
|
Participant1ID uint
|
|
Participant1 Participant `gorm:"foreignKey:Participant1ID"`
|
|
Participant2ID uint
|
|
Participant2 Participant `gorm:"foreignKey:Participant2ID"`
|
|
WinnerParticipantID uint
|
|
WinnerParticipant Participant `gorm:"foreignKey:WinnerParticipantID"`
|
|
}
|