mirror of
https://github.com/MADTeacher/go_basics.git
synced 2025-11-23 21:34:47 +02:00
Крестики-нолики с БД
This commit is contained in:
31
part_6/tic_tac_toe_v5/database/models.go
Normal file
31
part_6/tic_tac_toe_v5/database/models.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package database
|
||||
|
||||
import "time"
|
||||
|
||||
type Player struct {
|
||||
NickName string `gorm:"primary_key;not null"`
|
||||
}
|
||||
|
||||
type PlayerFinishGame struct {
|
||||
ID int `gorm:"primary_key;autoIncrement;not null"`
|
||||
WinnerName string `gorm:"not null"`
|
||||
BoardJSON []byte `gorm:"type:json;not null"`
|
||||
PlayerFigure int `gorm:"not null"`
|
||||
Time time.Time `gorm:"not null"`
|
||||
PlayerNickName string `gorm:"not null"`
|
||||
Player *Player `gorm:"foreignKey:PlayerNickName;references:NickName"`
|
||||
}
|
||||
|
||||
// GameSnapshot представляет модель для хранения снапшота игры в БД
|
||||
type GameSnapshot struct {
|
||||
ID int `gorm:"primaryKey;autoIncrement;not null"`
|
||||
SnapshotName string `gorm:"not null"`
|
||||
BoardJSON []byte `gorm:"type:json;not null"`
|
||||
PlayerFigure int `gorm:"not null"`
|
||||
State int `gorm:"not null"`
|
||||
Mode int `gorm:"not null"`
|
||||
Difficulty int `gorm:"not null"`
|
||||
IsCurrentFirst bool `gorm:"not null"`
|
||||
PlayerNickName string `gorm:"not null"`
|
||||
Player *Player `gorm:"foreignKey:PlayerNickName;references:NickName"`
|
||||
}
|
||||
Reference in New Issue
Block a user