This commit is contained in:
aozhiwei 2024-06-13 17:51:25 +08:00
parent 56585dbece
commit 4dd828b197
5 changed files with 59 additions and 16 deletions

View File

@ -1,6 +1,6 @@
[
{
"instance_id": 1,
"http_listen_port": 9993
"http_listen_port": 9996
}
]

View File

@ -1,8 +1,11 @@
package asset
import (
"q5"
"f5"
"mt"
"main/constant"
"fmt"
"strings"
"github.com/gin-gonic/gin"
)
@ -10,19 +13,41 @@ type AssetApi struct {
}
/*
filterType: 0:全部 1:已上架 2:未上架
*/
func (this *AssetApi) AccountAsset(c *gin.Context) {
netId := c.Param("netId")
tokenId := c.Param("tokenId")
f5.GetHttpCliMgr().SendGoStyleRequest(
mt.Table.Config.GetGameApiUrl() + "/webapp/index.php",
map[string]string{
"c": "OutAppNft",
"a": "nftMetaView",
"nft_type": "hero",
"net_id": netId,
"token_id": tokenId,
pageSize := q5.ToInt32(c.DefaultQuery("page_size", ""))
cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
netId := q5.ToInt64(c.Param("net_id"))
accountAddress := strings.ToLower(c.Param("account_address"))
//searchName := c.DefaultQuery("search_name", "")
filterType := q5.ToInt32(c.DefaultQuery("type", ""))
sql := fmt.Sprintf(`
SELECT A.idx, A.net_id, A.token_type, A.token_id, B.status FROM t_nft A LEFT JOIN t_order B
ON A.net_id = B.net_id AND A.contract_address = B.contract_address AND A.token_id = B.token_id
WHERE A.idx > %d AND A.net_id = %d AND A.owner_address=? LIMIT %d`,
cursor, netId, pageSize + 1)
if filterType == 1 {
sql += "B.status = '" + constant.ORDER_STATUS_ACTIVE + "'"
} else if filterType == 2 {
sql += "B.status <> '" + constant.ORDER_STATUS_ACTIVE + "'"
}
f5.GetGoStyleDb().StreamPageQuery(
constant.BCNFT_DB,
pageSize,
cursor,
sql,
[]string{
accountAddress,
},
func (rsp f5.HttpCliResponse) {
c.String(200, rsp.GetRawData())
f5.GetDbFilter().Comp(
),
"",
func (err error, pagination *f5.StreamPagination) {
},
func (ds *f5.DataSet) {
})
}

View File

@ -3,6 +3,7 @@ package app
import (
"f5"
"mt"
"main/constant"
)
type app struct {
@ -11,7 +12,7 @@ type app struct {
}
func (this *app) GetPkgName() string {
return "nftserver"
return "marketserver"
}
func (this *app) GetHttpListenPort() int32 {
@ -38,6 +39,14 @@ func (this *app) Update() {
}
func (this *app) registerDataSources() {
f5.GetGoStyleDb().RegisterDataSource(
constant.BCNFT_DB,
mt.Table.NftDb.GetById(0).GetHost(),
mt.Table.NftDb.GetById(0).GetPort(),
mt.Table.NftDb.GetById(0).GetUser(),
mt.Table.NftDb.GetById(0).GetPasswd(),
mt.Table.NftDb.GetById(0).GetDatabase(),
3)
}
func (this *app) HasTask() bool {

View File

@ -9,3 +9,12 @@ const (
ROUTER_MGR_MODULE_IDX
MAX_MODULE_IDX
)
const (
ORDER_STATUS_PENDING = "PENDING"
ORDER_STATUS_ACTIVE = "ACTIVE"
ORDER_STATUS_INACTIVE = "INACTIVE"
ORDER_STATUS_CANCELLED = "CANCELLED"
ORDER_STATUS_FILLED = "FILLED"
ORDER_STATUS_EXPIRED = "EXPIRED"
)

2
third_party/f5 vendored

@ -1 +1 @@
Subproject commit 684e548134643975d38213c017ac4cdb5577a8c0
Subproject commit ee715d672d83932a6a20f810cc490d737fad01e6