This commit is contained in:
aozhiwei 2024-07-16 13:50:04 +08:00
commit 4e4bec1f21
3 changed files with 95 additions and 4 deletions

View File

@ -14,7 +14,7 @@ import (
type PlayerApi struct {
}
func (this *PlayerApi) Info(c *gin.Context) {
func (pai *PlayerApi) Info(c *gin.Context) {
type InfoForm struct {
Playername string `json:"playername"`
AccurateName bool `json:"accurate_name"`
@ -57,7 +57,7 @@ func (this *PlayerApi) Info(c *gin.Context) {
})
}
func (this *PlayerApi) BagQuery(c *gin.Context) {
func (pai *PlayerApi) BagQuery(c *gin.Context) {
type BagQueryForm struct {
Account_id string `binding:"required" json:"account_id"`
}
@ -78,7 +78,7 @@ func (this *PlayerApi) BagQuery(c *gin.Context) {
})
}
func (this *PlayerApi) HeroesQuery(c *gin.Context) {
func (pai *PlayerApi) HeroesQuery(c *gin.Context) {
type HeroesQueryForm struct {
Account_id string `binding:"required" json:"account_id"`
}
@ -98,3 +98,37 @@ func (this *PlayerApi) HeroesQuery(c *gin.Context) {
return p
})
}
func (pai *PlayerApi) GoldBullionQuery(c *gin.Context) {
type GoldBullionQueryForm struct {
Token_id string `json:"token_id"`
Open_address string `json:"open_address"`
}
reqJson := GoldBullionQueryForm{}
if !checkparam(&reqJson, c) {
return
}
filterstr := ""
if reqJson.Token_id != "" {
filterstr = " token_id = '" + reqJson.Token_id + "'"
} else if reqJson.Open_address != "" {
filterstr = " open_address = '" + reqJson.Open_address + "'"
} else {
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": "input one of token_id, open_address",
})
return
}
cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
sql := fmt.Sprintf(`SELECT * FROM t_gold_bullion WHERE idx > %d AND %s `, cursor, filterstr)
query(constant.GAME_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} {
p := new(system.GoldBullion)
p.LoadFromDs(ds)
return p
})
}

View File

@ -0,0 +1,56 @@
package system
import (
"f5"
"q5"
)
type GoldBullion struct {
Idx int64 `json:"idx"`
Src_account_id string `gorm:"comment:账号id(channel + '_' + gameid + '_' + openid)" json:"src_account_id"`
Src_address string `gorm:"comment:src_address" json:"src_address"`
Token_id string `gorm:"uniqueIndex;comment:token_id" json:"token_id"`
Net_id int `gorm:"comment:net_id" json:"net_id"`
Item_id int `gorm:"comment:道具id" json:"item_id"`
Gold int `gorm:"comment:金币" json:"gold"`
Status int `gorm:"comment:状态 0:初始 1:已开" json:"status"`
Open_status int `gorm:"comment:1: 已发送 2未发送 3:已领取" json:"open_status"`
Open_address string `gorm:"comment:1: open_address" json:"open_address"`
Open_time int `gorm:"comment:open_time" json:"open_time"`
Open_account_id string `gorm:"comment:open账号id(channel + '_' + gameid + '_' + openid)" json:"open_account_id"`
Open_uniqid string `gorm:"comment:1: 开启的本次唯一id" json:"open_uniqid"`
Returned int `gorm:"comment:是否已超时返还" json:"returned"`
Return_time int `gorm:"comment:返还时间" json:"return_time"`
Activated int `gorm:"comment:是否已上连" json:"activated"`
Activated_time int `gorm:"comment:上链时间" json:"activated_time"`
Createtime int `gorm:"comment:创建时间" json:"createtime"`
Modifytime int `gorm:"comment:修改时间" json:"modifytime"`
Return_status int `gorm:"comment:1: 已发送 2:已领取" json:"return_status"`
}
func (gb *GoldBullion) TableName() string {
return "t_gold_bullion"
}
func (gb *GoldBullion) LoadFromDs(ds *f5.DataSet) {
gb.Idx = q5.ToInt64(ds.GetByName("idx"))
gb.Src_account_id = ds.GetByName("src_account_id")
gb.Src_address = ds.GetByName("src_address")
gb.Token_id = ds.GetByName("token_id")
gb.Net_id = q5.ToInt(ds.GetByName("net_id"))
gb.Item_id = q5.ToInt(ds.GetByName("item_id"))
gb.Gold = q5.ToInt(ds.GetByName("gold"))
gb.Status = q5.ToInt(ds.GetByName("status"))
gb.Open_status = q5.ToInt(ds.GetByName("open_status"))
gb.Open_address = ds.GetByName("open_address")
gb.Open_time = q5.ToInt(ds.GetByName("open_time"))
gb.Open_account_id = ds.GetByName("open_account_id")
gb.Open_uniqid = ds.GetByName("open_uniqid")
gb.Returned = q5.ToInt(ds.GetByName("returned"))
gb.Return_time = q5.ToInt(ds.GetByName("return_time"))
gb.Activated = q5.ToInt(ds.GetByName("activated"))
gb.Activated_time = q5.ToInt(ds.GetByName("activated_time"))
gb.Createtime = q5.ToInt(ds.GetByName("createtime"))
gb.Modifytime = q5.ToInt(ds.GetByName("modifytime"))
gb.Return_status = q5.ToInt(ds.GetByName("return_status"))
}

View File

@ -8,12 +8,13 @@ import (
type PlayerRouter struct{}
func (this *PlayerRouter) InitPlayerRouter(priRouter *gin.RouterGroup) {
func (pr *PlayerRouter) InitPlayerRouter(priRouter *gin.RouterGroup) {
group := priRouter.Group("player")
api := v1.ApiGroupApp.SystemApiGroup.PlayerApi
{
group.POST("info", api.Info)
group.POST("bagquery", api.BagQuery)
group.POST("heroesquery", api.HeroesQuery)
group.POST("goldbullionquery", api.GoldBullionQuery)
}
}