1
0
mirror of https://github.com/MADTeacher/go_basics.git synced 2025-11-23 21:34:47 +02:00

Крестики-нолики с БД

This commit is contained in:
Stanislav Chernyshev
2025-06-17 15:48:17 +03:00
parent 48f742916d
commit fcc93b5343
30 changed files with 1418 additions and 299 deletions

View 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"`
}