This commit is contained in:
aozhiwei 2024-06-13 11:09:58 +08:00
parent b566b8263e
commit a1b755aebd
12 changed files with 125 additions and 97 deletions

View File

@ -0,0 +1,28 @@
package asset
import (
"f5"
"mt"
"github.com/gin-gonic/gin"
)
type AssetApi struct {
}
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,
},
func (rsp f5.HttpCliResponse) {
c.String(200, rsp.GetRawData())
})
}

View File

@ -1,5 +1,5 @@
package nft
package asset
type ApiGroup struct {
NftMetaApi
AssetApi
}

View File

@ -1,11 +1,13 @@
package v1
import (
"main/api/v1/nft"
"main/api/v1/market"
"main/api/v1/asset"
)
type ApiGroup struct {
NftApiGroup nft.ApiGroup
MarketApiGroup market.ApiGroup
AssetApiGroup asset.ApiGroup
}
var ApiGroupApp = new(ApiGroup)

View File

@ -0,0 +1,5 @@
package market
type ApiGroup struct {
MarketApi
}

View File

@ -0,0 +1,45 @@
package market
import (
"f5"
"mt"
"github.com/gin-gonic/gin"
)
type MarketApi struct {
}
func (this *MarketApi) ProductList(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,
},
func (rsp f5.HttpCliResponse) {
c.String(200, rsp.GetRawData())
})
}
func (this *MarketApi) TransactionHistory(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": "gold_bullion",
"net_id": netId,
"token_id": tokenId,
},
func (rsp f5.HttpCliResponse) {
c.String(200, rsp.GetRawData())
})
}

View File

@ -1,72 +0,0 @@
package nft
import (
"f5"
"mt"
"main/common"
"github.com/gin-gonic/gin"
)
type NftMetaApi struct {
}
func (this *NftMetaApi) Hero(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,
},
func (rsp f5.HttpCliResponse) {
c.String(200, rsp.GetRawData())
})
}
func (this *NftMetaApi) GoldBullion(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": "gold_bullion",
"net_id": netId,
"token_id": tokenId,
},
func (rsp f5.HttpCliResponse) {
c.String(200, rsp.GetRawData())
})
}
func (this *NftMetaApi) HeroHome(c *gin.Context) {
meta := mt.Table.NftHomeMeta.GetHeroMeta()
rspObj := new(common.NftHomeMeta)
if meta != nil {
rspObj.Name = meta.GetNftName()
rspObj.Symbol = meta.GetNftSymbol()
rspObj.Description = meta.GetNftDescription()
rspObj.Image = meta.GetNftImage()
rspObj.ExternalLink = meta.GetNftExternalLink()
}
c.JSON(200, rspObj)
}
func (this *NftMetaApi) GoldBullionHome(c *gin.Context) {
meta := mt.Table.NftHomeMeta.GetGoldBullionMeta()
rspObj := new(common.NftHomeMeta)
if meta != nil {
rspObj.Name = meta.GetNftName()
rspObj.Symbol = meta.GetNftSymbol()
rspObj.Description = meta.GetNftDescription()
rspObj.Image = meta.GetNftImage()
rspObj.ExternalLink = meta.GetNftExternalLink()
}
c.JSON(200, rspObj)
}

View File

@ -0,0 +1,13 @@
package asset
import (
"f5"
"main/api/v1"
)
type AssetRouter struct{}
func (this *AssetRouter) InitRouter() {
api := v1.ApiGroupApp.AssetApiGroup
f5.GetApp().GetGinEngine().GET("/api/asset/:net_id/:account_address", api.AssetApi.AccountAsset)
}

View File

@ -1,5 +1,5 @@
package nft
package asset
type RouterGroup struct {
NftMetaRouter
AssetRouter
}

View File

@ -0,0 +1,5 @@
package market
type RouterGroup struct {
MarketRouter
}

View File

@ -0,0 +1,15 @@
package market
import (
"f5"
"main/api/v1"
)
type MarketRouter struct{}
func (this *MarketRouter) InitRouter() {
api := v1.ApiGroupApp.MarketApiGroup
f5.GetApp().GetGinEngine().GET("/api/market/product/list/:net_id", api.MarketApi.ProductList)
f5.GetApp().GetGinEngine().GET("/api/market/transaction/history/:net_id/:account_address",
api.MarketApi.TransactionHistory)
}

View File

@ -1,16 +0,0 @@
package nft
import (
"f5"
"main/api/v1"
)
type NftMetaRouter struct{}
func (this *NftMetaRouter) InitRouter() {
api := v1.ApiGroupApp.NftApiGroup
f5.GetApp().GetGinEngine().GET("hero/meta/:netId/:tokenId", api.NftMetaApi.Hero)
f5.GetApp().GetGinEngine().GET("gold_bullion/meta/:netId/:tokenId", api.NftMetaApi.GoldBullion)
f5.GetApp().GetGinEngine().GET("hero/home_meta/:netId", api.NftMetaApi.HeroHome)
f5.GetApp().GetGinEngine().GET("gold_bullion/home_meta/:netId", api.NftMetaApi.GoldBullionHome)
}

View File

@ -2,11 +2,13 @@ package router
import (
"f5"
"main/router/nft"
"main/router/market"
"main/router/asset"
)
type routerMgr struct {
nft nft.RouterGroup
market market.RouterGroup
asset asset.RouterGroup
}
func (this *routerMgr) Init() {
@ -14,7 +16,8 @@ func (this *routerMgr) Init() {
f5.GetApp().GetGinEngine().Use(middleware.Cors())
*/
this.nft.NftMetaRouter.InitRouter()
this.market.MarketRouter.InitRouter()
this.asset.AssetRouter.InitRouter()
f5.GetSysLog().Info("routerMgr.init")