存档功能

This commit is contained in:
李琦
2026-09-24 16:53:46 +08:00
parent 81159196b1
commit f58eb7b276
5 changed files with 407 additions and 44 deletions

View File

@@ -1,16 +1,17 @@
package model
// GameSave 游戏存档表:支持存档的单机游戏(如饥荒)一人一游戏一份快照
// GameSave 游戏存档表:支持存档的单机游戏(如饥荒)一人可有多份命名快照
// 快照内容由前端游戏自行序列化(JSON 字符串),后端只负责存取
type GameSave struct {
ID int `gorm:"primaryKey" json:"id"` // 存档ID
UserID int `gorm:"uniqueIndex:uk_user_game" json:"user_id"` // 玩家用户ID
GameID int `gorm:"uniqueIndex:uk_user_game" json:"game_id"` // 游戏ID
Day int `gorm:"default:1" json:"day"` // 存档进度天数(列表/继续面板展示用)
Score int `gorm:"default:0" json:"score"` // 存档时分数(展示用)
Data string `gorm:"type:mediumtext" json:"data"` // 游戏状态快照(JSON 字符串,前端序列化)
CreatedAt int64 `gorm:"autoCreateTime" json:"created_at"` // 创建时间(int 时间戳)
UpdatedAt int64 `gorm:"autoUpdateTime" json:"updated_at"` // 更新时间(int 时间戳)
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 指定表名