This commit is contained in:
aozhiwei 2024-06-16 10:13:26 +08:00
parent 4dfdb049c6
commit fdec315fba
4 changed files with 31 additions and 6 deletions

View File

@ -44,7 +44,9 @@ WHERE A.idx > %d AND A.net_id = %d AND A.owner_address=? LIMIT %d`,
ErrMsg string `json:"errmsg"`
Page common.StreamPagination `json:"page"`
Rows []interface{} `json:"rows"`
}{}
}{
Rows : []interface{}{},
}
nfts := []*common.NftDto{}
f5.GetGoStyleDb().StreamPageQuery(
constant.BCNFT_DB,
@ -68,5 +70,10 @@ WHERE A.idx > %d AND A.net_id = %d AND A.owner_address=? LIMIT %d`,
q5.AppendSlice(&nfts, p)
})
GetCacheMgr().GetNfts(nfts)
{
for _, val := range nfts {
q5.AppendSlice(&rspObj.Rows, val.NftCache.GetJsonData())
}
}
c.JSON(200, rspObj)
}

View File

@ -1,6 +1,7 @@
package cache
import (
"q5"
"f5"
"mt"
"sync"
@ -41,11 +42,18 @@ func (this *cacheMgr) internalGetNft(dto *common.NftDto) {
map[string]string{
"c": "OutAppNft",
"a": "nftDetail",
"nft_type": "gold_bullion",
//"net_id": netId,
//"token_id": tokenId,
"nft_type": "hero",
"net_id": q5.ToString(dto.NetId),
"token_id": dto.TokenId,
},
func (rsp f5.HttpCliResponse) {
if rsp.GetErr() == nil {
p := new(nft)
jsonRsp := map[string]interface{}{}
q5.DecodeJson(rsp.GetRawData(), &jsonRsp)
p.jsonData = jsonRsp
dto.NftCache = p
}
})
}
}

View File

@ -3,8 +3,13 @@ package cache
type nft struct {
refreshTime int32
rawData string
jsonData interface{}
}
func (this *nft) GetRawData() string {
return this.rawData
}
func (this *nft) GetJsonData() interface{} {
return this.jsonData
}

View File

@ -44,6 +44,7 @@ type StreamPagination struct {
type NftCache interface {
GetRawData() string
GetJsonData() interface{}
}
type NftDto struct {
@ -69,7 +70,11 @@ type CacheMgr interface{
func (this* StreamPagination) FillPage(page *f5.StreamPagination) {
this.NextCursor = q5.ToString(page.NextCursor)
this.PreviousCursor = q5.ToString(page.PreviousCursor)
if page.NextCursor != 0 {
this.NextCursor = q5.ToString(page.NextCursor)
}
if page.PreviousCursor != 0 {
this.PreviousCursor = q5.ToString(page.PreviousCursor)
}
this.Remaining = page.Remaining
}