质押查询
This commit is contained in:
parent
9c1e3693d4
commit
4a5733841b
111
server/marketserver/api/v1/market/marketsecondary.go
Normal file
111
server/marketserver/api/v1/market/marketsecondary.go
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
package market
|
||||||
|
|
||||||
|
import (
|
||||||
|
"f5"
|
||||||
|
"fmt"
|
||||||
|
"main/common"
|
||||||
|
"main/constant"
|
||||||
|
. "main/global"
|
||||||
|
"net/http"
|
||||||
|
"q5"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (this *MarketApi) LockList(c *gin.Context) {
|
||||||
|
netId := q5.ToInt64(c.Param("net_id"))
|
||||||
|
owner := c.Param("owner_address")
|
||||||
|
reqJson := struct {
|
||||||
|
PageSize interface{} `json:"page_size"`
|
||||||
|
Cursor interface{} `json:"cursor"`
|
||||||
|
Search struct {
|
||||||
|
} `json:"search"`
|
||||||
|
Filter struct {
|
||||||
|
ItemIds []interface{} `json:"item_ids"`
|
||||||
|
} `json:"filter"`
|
||||||
|
Sort struct {
|
||||||
|
Fields [] struct {
|
||||||
|
} `json:"fields"`
|
||||||
|
} `json:"sort"`
|
||||||
|
}{}
|
||||||
|
if err := c.ShouldBindJSON(&reqJson); err != nil {
|
||||||
|
c.JSON(http.StatusOK, gin.H{
|
||||||
|
"code": 1,
|
||||||
|
"message": err.Error(),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
pageSize := q5.AdjustRangeValue(q5.SafeToInt32(reqJson.PageSize), 1, 20)
|
||||||
|
cursor := q5.SafeToInt64(reqJson.Cursor)
|
||||||
|
sql := fmt.Sprintf(`
|
||||||
|
SELECT * FROM t_nft WHERE idx > %d AND net_id = %d AND owner_address = '%s' AND owner_address = last_lock_address
|
||||||
|
`,
|
||||||
|
cursor, netId, owner)
|
||||||
|
|
||||||
|
subFilters := []f5.DbQueryFilter{}
|
||||||
|
|
||||||
|
{
|
||||||
|
itemIds := map[int32]int32{}
|
||||||
|
for _, val := range(reqJson.Filter.ItemIds) {
|
||||||
|
itemId := q5.SafeToInt32(val)
|
||||||
|
itemIds[itemId] = 1
|
||||||
|
}
|
||||||
|
if len(itemIds) > 0 {
|
||||||
|
inSub := `item_id IN (`
|
||||||
|
i := 0
|
||||||
|
for key, _ := range(itemIds) {
|
||||||
|
if i == 0 {
|
||||||
|
inSub += q5.ToString(key)
|
||||||
|
} else {
|
||||||
|
inSub += "," + q5.ToString(key)
|
||||||
|
}
|
||||||
|
i += 1
|
||||||
|
}
|
||||||
|
inSub += ")"
|
||||||
|
q5.AppendSlice(&subFilters, f5.GetDbFilter().Custom(inSub).And())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rspObj := struct {
|
||||||
|
ErrCode int32 `json:"errcode"`
|
||||||
|
ErrMsg string `json:"errmsg"`
|
||||||
|
Page common.StreamPagination `json:"page"`
|
||||||
|
Rows []struct{
|
||||||
|
Event interface{} `json:"event"`
|
||||||
|
Nft interface{} `json:"nft"`
|
||||||
|
} `json:"rows"`
|
||||||
|
}{}
|
||||||
|
q5.NewSlice(&rspObj.Rows, 0, 10)
|
||||||
|
nfts := []*common.NftDto{}
|
||||||
|
orderBy := ""
|
||||||
|
f5.GetGoStyleDb().StreamPageQuery(
|
||||||
|
constant.BCNFT_DB,
|
||||||
|
pageSize,
|
||||||
|
cursor,
|
||||||
|
sql,
|
||||||
|
[]string{
|
||||||
|
},
|
||||||
|
f5.GetDbFilter().Comp(subFilters...),
|
||||||
|
orderBy,
|
||||||
|
func (err error, pagination *f5.StreamPagination) {
|
||||||
|
rspObj.Page.FillPage(pagination)
|
||||||
|
},
|
||||||
|
func (ds *f5.DataSet) {
|
||||||
|
p := new(common.NftDto)
|
||||||
|
p.NetId = q5.ToInt32(ds.GetByName("net_id"))
|
||||||
|
p.ContractAddress = ds.GetByName("contract_address")
|
||||||
|
p.TokenId = ds.GetByName("token_id")
|
||||||
|
p.Payload = map[string]interface{}{}
|
||||||
|
q5.AppendSlice(&nfts, p)
|
||||||
|
})
|
||||||
|
GetCacheMgr().GetNfts(nfts)
|
||||||
|
{
|
||||||
|
for _, val := range nfts {
|
||||||
|
p := q5.NewSliceElement(&rspObj.Rows)
|
||||||
|
p.Event = val.Payload
|
||||||
|
p.Nft = val.NftCache.GetJsonData()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.JSON(200, rspObj)
|
||||||
|
}
|
@ -2,7 +2,7 @@ package market
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"f5"
|
"f5"
|
||||||
"main/api/v1"
|
v1 "main/api/v1"
|
||||||
"main/middleware"
|
"main/middleware"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -23,4 +23,7 @@ func (this *MarketRouter) InitRouter() {
|
|||||||
f5.GetApp().GetGinEngine().GET("/api/market/product/goods/:net_id/:contract_address/:token_id",
|
f5.GetApp().GetGinEngine().GET("/api/market/product/goods/:net_id/:contract_address/:token_id",
|
||||||
middleware.MaybeJwtAuth,
|
middleware.MaybeJwtAuth,
|
||||||
api.MarketApi.Goods)
|
api.MarketApi.Goods)
|
||||||
|
f5.GetApp().GetGinEngine().POST("/api/market/product/lock/:net_id/:owner_address/",
|
||||||
|
middleware.MaybeJwtAuth,
|
||||||
|
api.MarketApi.LockList)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user