This commit is contained in:
aozhiwei 2024-06-16 18:28:38 +08:00
parent 38460a1465
commit 9742748b9c

View File

@ -89,11 +89,14 @@ func (this *cacheMgr) batchGetNfts(nfts []*common.NftDto) {
rspObj := struct { rspObj := struct {
ErrCode interface{} `json:"errcode"` ErrCode interface{} `json:"errcode"`
ErrMsg string `json:"errmsg"` ErrMsg string `json:"errmsg"`
Nfts []map[string]interface{} `json:"nfts"`
/*
Nfts [] struct { Nfts [] struct {
NetId interface{} `json:"errmsg"` NetId interface{} `json:"errmsg"`
ContractAddress string `json:"contract_address"` ContractAddress string `json:"contract_address"`
TokenId interface{} `json:"token_id"` TokenId interface{} `json:"token_id"`
} `json:"nfts"` } `json:"nfts"`
*/
}{} }{}
params := struct { params := struct {
Nfts []struct { Nfts []struct {
@ -118,17 +121,32 @@ func (this *cacheMgr) batchGetNfts(nfts []*common.NftDto) {
} }
if rsp.JsonParseOk() { if rsp.JsonParseOk() {
for _, val := range rspObj.Nfts { for _, val := range rspObj.Nfts {
netId := q5.SafeToInt32(val.NetId) var netId int32
contractAddress := q5.ToString(val.ContractAddress) var contractAddress string
tokenId := q5.SafeToString(val.TokenId) var tokenId string
for _, val2 := range nfts { if p, ok := val["net_id"]; ok {
if val2.NetId == netId && netId = q5.SafeToInt32(p)
val2.ContractAddress == contractAddress && } else {
val2.TokenId == tokenId { continue
}
} }
if p, ok := val["contract_address"]; ok {
contractAddress = q5.SafeToString(p)
} else {
continue
}
if p, ok := val["token_id"]; ok {
tokenId = q5.SafeToString(p)
} else {
continue
}
this.addNft(netId, contractAddress, tokenId)
} }
} }
}) })
} }
func (this *cacheMgr) addNft(netId int32, contractAddress string, tokenId string) {
dto := new(common.NftDto)
p := newNft()
this.nftHash.Store(dto.GetKey(), p)
}