38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
|
package models
|
||
|
|
||
|
import (
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
type Team struct {
|
||
|
Model
|
||
|
Name string `gorm:"unique,not_null" json:"name"`
|
||
|
Members []*TeamMember `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"members"`
|
||
|
Requests []*TeamRequest `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"-"`
|
||
|
Games []*TeamAtGame `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"-"`
|
||
|
}
|
||
|
|
||
|
type TeamMember struct {
|
||
|
Team *Team `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"team"`
|
||
|
TeamID uint `gorm:"primaryKey" json:"-"`
|
||
|
User *User `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"-"`
|
||
|
UserID uint `gorm:"primaryKey" json:"-"`
|
||
|
Role Role `json:"role"`
|
||
|
CreatedAt time.Time `json:"-"`
|
||
|
}
|
||
|
|
||
|
type TeamRequest struct {
|
||
|
Team *Team `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
|
||
|
TeamID uint `gorm:"primaryKey"`
|
||
|
User *User `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
|
||
|
UserID uint `gorm:"primaryKey"`
|
||
|
CreatedAt time.Time
|
||
|
}
|
||
|
|
||
|
type Role int
|
||
|
|
||
|
const (
|
||
|
Captain Role = iota
|
||
|
Member
|
||
|
)
|