2025-06-21 00:58:22 +08:00
|
|
|
|
package user
|
|
|
|
|
|
2025-06-23 01:23:27 +08:00
|
|
|
|
import "time"
|
|
|
|
|
|
2025-06-21 00:58:22 +08:00
|
|
|
|
// 玩家账户表
|
|
|
|
|
type UserResources struct {
|
2025-06-23 01:23:27 +08:00
|
|
|
|
UID int64 `gorm:"primaryKey" json:"uid"`
|
2025-06-21 00:58:22 +08:00
|
|
|
|
Gold int64 `gorm:"default:0" json:"gold"` // 金币
|
|
|
|
|
Diamond int64 `gorm:"default:0" json:"diamond"` // 钻石
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (u UserResources) GetId() int64 {
|
|
|
|
|
return u.UID
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-23 01:23:27 +08:00
|
|
|
|
func (u UserResources) GetIdName() string {
|
|
|
|
|
return "uid"
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-21 00:58:22 +08:00
|
|
|
|
func (u UserResources) TableName() string {
|
|
|
|
|
return "user_resources"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type UserResourcesLog struct {
|
2025-06-23 01:23:27 +08:00
|
|
|
|
UID int64 `gorm:"type:Int64;index" json:"uid"` // 玩家id
|
|
|
|
|
Time time.Time `gorm:"type:DateTime;default:now()" json:"time"` // 修改时间
|
|
|
|
|
ResName string `gorm:"type:String;not null" json:"res_name"` // 资源名
|
|
|
|
|
ResAddValue int64 `gorm:"type:Int64;" json:"res_value"` // 资源增加值
|
|
|
|
|
ResAfterValue int64 `gorm:"type:Int64;" json:"res_after_value"` // 资源增加后的值
|
|
|
|
|
GameId int `gorm:"type:Int32;" json:"game_id"` // 添加资源的玩法id,充值等非玩法操作资源,则为0
|
|
|
|
|
GameNo string `gorm:"type:String" json:"game_no"` // 游戏局id,同上
|
|
|
|
|
Reason string `gorm:"type:String" json:"reason"` // 原因
|
|
|
|
|
OperatorId int64 `gorm:"type:Int64;" json:"operator_id"` // 操作者id
|
2025-06-21 00:58:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (u UserResourcesLog) GetId() int64 {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-23 01:23:27 +08:00
|
|
|
|
func (u UserResourcesLog) GetIdName() string {
|
|
|
|
|
return "uid"
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-21 00:58:22 +08:00
|
|
|
|
func (u UserResourcesLog) TableName() string {
|
|
|
|
|
return "user_resources_log"
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-23 01:23:27 +08:00
|
|
|
|
func (u UserResourcesLog) TableOptions() string {
|
|
|
|
|
// "ENGINE=MergeTree() ORDER BY tuple()"
|
|
|
|
|
return `ENGINE=MergeTree()
|
|
|
|
|
ORDER BY (uid, time)
|
|
|
|
|
PARTITION BY toYYYYMM(time)
|
|
|
|
|
TTL time + INTERVAL 6 MONTH
|
|
|
|
|
`
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-21 00:58:22 +08:00
|
|
|
|
type AddUserRes struct {
|
|
|
|
|
GameId int `json:"game_id"` // 添加资源的玩法id,充值等非玩法操作资源,则为0
|
|
|
|
|
GameNo string `json:"game_no"` // 游戏局id,同上
|
|
|
|
|
Reason string `json:"reason"` // 原因
|
|
|
|
|
AddRes map[string]int64 `json:"add_res"` // map[资源名]增加值
|
|
|
|
|
}
|