diff --git a/server/marketserver/api/v1/asset/asset.go b/server/marketserver/api/v1/asset/asset.go index c9d924e5..a652adab 100644 --- a/server/marketserver/api/v1/asset/asset.go +++ b/server/marketserver/api/v1/asset/asset.go @@ -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) } diff --git a/server/marketserver/cache/cachemgr.go b/server/marketserver/cache/cachemgr.go index 2c45bff1..f7c7e2a5 100644 --- a/server/marketserver/cache/cachemgr.go +++ b/server/marketserver/cache/cachemgr.go @@ -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 + } }) } } diff --git a/server/marketserver/cache/nft.go b/server/marketserver/cache/nft.go index 017da6fc..044f4f14 100644 --- a/server/marketserver/cache/nft.go +++ b/server/marketserver/cache/nft.go @@ -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 +} diff --git a/server/marketserver/common/types.go b/server/marketserver/common/types.go index 95a92d87..ed6d345c 100644 --- a/server/marketserver/common/types.go +++ b/server/marketserver/common/types.go @@ -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 }