This commit is contained in:
aozhiwei 2024-07-21 03:10:03 +08:00
parent ce8a05cc4b
commit c29e48f7da
2 changed files with 51 additions and 1 deletions

View File

@ -1,7 +1,13 @@
package activity
import (
"q5"
"f5"
"mt"
"jccommon"
"main/constant"
"github.com/gin-gonic/gin"
"strings"
)
type StackingApi struct {
@ -9,12 +15,50 @@ type StackingApi struct {
}
func (this *StackingApi) ExpectedDaily(c *gin.Context) {
//accountAddress := strings.ToLower(c.Param("account_address"))
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)
}

View File

@ -107,3 +107,9 @@ func (this *ContractTable) GetByNetIdAddress(netId int32, address string) *Contr
return nil
}
}
func (this *ContractTable) Traverse(cb func(*Contract) bool) {
this.netIdNameHash.Range(func (k string, v *Contract) bool {
return cb(v)
})
}