This commit is contained in:
aozhiwei 2024-10-29 16:21:58 +08:00
parent 0ce6f37e39
commit a2e06ae3dd
7 changed files with 3 additions and 213 deletions

View File

@ -1,6 +0,0 @@
package nft
type ApiGroup struct {
NftMetaApi
NftDetailApi
}

View File

@ -1,61 +0,0 @@
package nft
import (
"q5"
"f5"
"main/mt"
"jccommon"
"github.com/gin-gonic/gin"
)
type NftDetailApi struct {
}
func (this *NftDetailApi) Hero(c *gin.Context) {
netId := q5.ToInt32(c.Param("netId"))
tokenId := c.Param("tokenId")
/*contractMeta := mt.Table.Contract.GetByNetIdName(netId, constant.CONTRACT_NAME_CFHero)
contractAddress := ""
if contractMeta != nil {
contractAddress = contractMeta.GetAddress()
}*/
f5.GetHttpCliMgr().SendGoStyleRequest(
mt.Table.Config.GetGameApiUrl() + "/webapp/index.php",
map[string]string{
"c": "OutAppNft",
"a": "nftDetailByTokenType",
//"contract_address": contractAddress,
"net_id": q5.ToString(netId),
"token_type": q5.ToString(jccommon.NFT_TYPE_CFHERO),
"token_id": tokenId,
},
func (rsp f5.HttpCliResponse) {
c.Data(200, "application/json", []byte(rsp.GetRawData()))
//c.String(200, rsp.GetRawData())
})
}
func (this *NftDetailApi) GoldBullion(c *gin.Context) {
netId := q5.ToInt32(c.Param("netId"))
tokenId := c.Param("tokenId")
/*
contractMeta := mt.Table.Contract.GetByNetIdName(netId, constant.CONTRACT_NAME_GoldBrick)
contractAddress := ""
if contractMeta != nil {
contractAddress = contractMeta.GetAddress()
}*/
f5.GetHttpCliMgr().SendGoStyleRequest(
mt.Table.Config.GetGameApiUrl() + "/webapp/index.php",
map[string]string{
"c": "OutAppNft",
"a": "nftDetailByTokenType",
//"contract_address": contractAddress,
"net_id": q5.ToString(netId),
"token_type": q5.ToString(jccommon.NFT_TYPE_GOLD_BULLION),
"token_id": tokenId,
},
func (rsp f5.HttpCliResponse) {
c.Data(200, "application/json", []byte(rsp.GetRawData()))
})
}

View File

@ -1,104 +0,0 @@
package nft
import (
"q5"
"f5"
"main/mt"
"jccommon"
"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",
"net_id": netId,
"token_type": q5.ToString(jccommon.NFT_TYPE_CFHERO),
"token_id": tokenId,
},
func (rsp f5.HttpCliResponse) {
c.Data(200, "application/json", []byte(rsp.GetRawData()))
})
}
func (this *NftMetaApi) NewHero(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",
"net_id": netId,
"token_type": q5.ToString(jccommon.NFT_TYPE_CFHERO_NORMAL),
"token_id": tokenId,
},
func (rsp f5.HttpCliResponse) {
c.Data(200, "application/json", []byte(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",
"net_id": netId,
"token_type": q5.ToString(jccommon.NFT_TYPE_GOLD_BULLION),
"token_id": tokenId,
},
func (rsp f5.HttpCliResponse) {
c.Data(200, "application/json", []byte(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) NewHeroHome(c *gin.Context) {
meta := mt.Table.NftHomeMeta.GetNewHeroMeta()
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

@ -1,6 +0,0 @@
package nft
type RouterGroup struct {
NftMetaRouter
NftDetailRouter
}

View File

@ -1,14 +0,0 @@
package nft
import (
"f5"
"main/api/v1"
)
type NftDetailRouter struct{}
func (this *NftDetailRouter) InitRouter() {
api := v1.ApiGroupApp.NftApiGroup
f5.GetApp().GetGinEngine().GET("/hero/detail/:netId/:tokenId", api.NftDetailApi.Hero)
f5.GetApp().GetGinEngine().GET("/gold_bullion/detail/:netId/:tokenId", api.NftDetailApi.GoldBullion)
}

View File

@ -1,18 +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("/newhero/meta/:netId/:tokenId", api.NftMetaApi.NewHero)
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("/newhero/home_meta/:netId", api.NftMetaApi.NewHeroHome)
f5.GetApp().GetGinEngine().GET("/gold_bullion/home_meta/:netId", api.NftMetaApi.GoldBullionHome)
}

View File

@ -2,19 +2,18 @@ package router
import (
"f5"
"main/router/nft"
//"main/router/nft"
)
type routerMgr struct {
nft nft.RouterGroup
}
func (this *routerMgr) Init() {
/*
f5.GetApp().GetGinEngine().Use(middleware.Cors())
*/
this.nft.NftMetaRouter.InitRouter()
this.nft.NftDetailRouter.InitRouter()
//this.nft.NftMetaRouter.InitRouter()
//this.nft.NftDetailRouter.InitRouter()
f5.GetSysLog().Info("routerMgr.init")