This commit is contained in:
aozhiwei 2024-07-21 03:40:29 +08:00
parent ec71264cad
commit ec36100f30

View File

@ -21,20 +21,73 @@ func (this *UserApi) Info(c *gin.Context) {
Gold float64 `json:"gold"` Gold float64 `json:"gold"`
}{ }{
} }
f5.GetGoStyleDb().OrmSelectOne( {
constant.GAME_DB, var dbErr error
"t_user", f5.GetGoStyleDb().OrmSelectOne(
[][]string{ constant.GAME_DB,
{"address", accountAddress}, "t_user",
}, [][]string{
func (err error, ds *f5.DataSet) { {"address", accountAddress},
if err != nil { },
f5.RspErr(c, 500, "server internal error") func (err error, ds *f5.DataSet) {
return dbErr = err
} if err != nil {
if ds.Next() { return
rspObj.Gold = q5.ToFloat64(ds.GetByName("gold")) }
} if ds.Next() {
c.JSON(200, rspObj) rspObj.Gold = q5.ToFloat64(ds.GetByName("gold"))
}) }
})
if dbErr != nil {
f5.RspErr(c, 500, "server internal error")
return
}
}
{
var dbErr error
f5.GetGoStyleDb().OrmSelectOne(
constant.BCNFT_DB,
"t_contribution",
[][]string{
{"account_address", accountAddress},
},
func (err error, ds *f5.DataSet) {
dbErr = err
if err != nil {
return
}
if ds.Next() {
rspObj.ContributionPoint += q5.ToInt64(ds.GetByName("contribution"))
}
})
if dbErr != nil {
f5.RspErr(c, 500, "server internal error")
return
}
}
{
var dbErr error
sql := "SELECT SUM(contribution) FROM t_staking_daily_settlement WHERE account_address = ?"
params := []string{
accountAddress,
}
f5.GetGoStyleDb().RawQuery(
constant.BCNFT_DB,
sql,
params,
func (err error, ds *f5.DataSet) {
dbErr = err
if err != nil {
return
}
for ds.Next() {
rspObj.ContributionPoint += q5.ToInt64(ds.GetByIndex(0))
}
})
if dbErr != nil {
f5.RspErr(c, 500, "server internal error")
return
}
}
c.JSON(200, rspObj)
} }