Files
nl-game-api/internal/model/save.go
2026-09-24 16:53:46 +08:00

19 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package model
// GameSave 游戏存档表:支持存档的单机游戏(如饥荒)一人可有多份命名快照
// 快照内容由前端游戏自行序列化(JSON 字符串),后端只负责存取
type GameSave struct {
ID int `gorm:"primaryKey" json:"id"` // 存档ID
UserID int `gorm:"index:idx_user_game" json:"user_id"` // 玩家用户ID
GameID int `gorm:"index:idx_user_game" json:"game_id"` // 游戏ID
Day int `gorm:"default:1" json:"day"` // 存档进度天数(列表展示用)
Score int `gorm:"default:0" json:"score"` // 存档时分数(展示用)
Name string `gorm:"size:64;default:冒险" json:"name"` // 存档显示名
Data string `gorm:"type:mediumtext" json:"data"` // 游戏状态快照(JSON 字符串)
CreatedAt int64 `gorm:"autoCreateTime" json:"created_at"` // 创建时间
UpdatedAt int64 `gorm:"autoUpdateTime" json:"updated_at"` // 更新时间
}
// TableName 指定表名
func (GameSave) TableName() string { return "game_saves" }