package user import ( "q5" "f5" "main/constant" "strings" "github.com/gin-gonic/gin" ) type UserApi struct { } func (this *UserApi) Info(c *gin.Context) { accountAddress := strings.ToLower(c.Param("account_address")) rspObj := struct { ErrCode int32 `json:"errcode"` ErrMsg string `json:"errmsg"` ContributionPoint int64 `json:"contribution_point"` Gold float64 `json:"gold"` }{ } { var dbErr error f5.GetGoStyleDb().OrmSelectOne( constant.GAME_DB, "t_user", [][]string{ {"address", accountAddress}, }, func (err error, ds *f5.DataSet) { dbErr = err if err != nil { return } if ds.Next() { 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) }