aozhiwei c29e48f7da 1
2024-07-21 03:10:03 +08:00

65 lines
1.2 KiB
Go

package activity
import (
"q5"
"f5"
"mt"
"jccommon"
"main/constant"
"github.com/gin-gonic/gin"
"strings"
)
type StackingApi struct {
}
func (this *StackingApi) ExpectedDaily(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"`
}{
}
{
sqlTpl := "SELECT * FROM t_nft WHERE token_type <> ? AND last_lock_address = ? AND owner_address IN ("
params := []string{
q5.ToString(jccommon.NFT_TYPE_GOLD_BULLION),
accountAddress,
}
{
lockMetas := []*mt.Contract{}
mt.Table.Contract.Traverse(func (ele *mt.Contract) bool {
if ele.GetName() == jccommon.CONTRACT_NAME_NFTLock {
q5.AppendSlice(&lockMetas, ele)
}
return true
})
if len(lockMetas)<= 0 {
c.JSON(200, rspObj)
return
}
inited := false
for _, lockMeta := range lockMetas {
if !inited {
inited = true
sqlTpl += "?"
} else {
sqlTpl += ",?"
}
q5.AppendSlice(&params, lockMeta.GetAddress())
}
sqlTpl += ")"
}
f5.GetGoStyleDb().RawQuery(
constant.BCNFT_DB,
"",
params,
func (err error, ds *f5.DataSet) {
})
}
c.JSON(200, rspObj)
}