game/common/model/user/userResources.go

63 lines
2.0 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 user
import "time"
// 玩家账户表
type UserResources struct {
UID int64 `gorm:"primaryKey" json:"uid"`
Gold int64 `gorm:"default:0" json:"gold"` // 金币
Diamond int64 `gorm:"default:0" json:"diamond"` // 钻石
}
func (u UserResources) GetId() int64 {
return u.UID
}
func (u UserResources) GetIdName() string {
return "uid"
}
func (u UserResources) TableName() string {
return "user_resources"
}
type UserResourcesLog struct {
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
}
func (u UserResourcesLog) GetId() int64 {
return 0
}
func (u UserResourcesLog) GetIdName() string {
return "uid"
}
func (u UserResourcesLog) TableName() string {
return "user_resources_log"
}
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
`
}
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[资源名]增加值
}