diff --git a/server/marketserver/api/v1/asset/asset.go b/server/marketserver/api/v1/asset/asset.go new file mode 100644 index 00000000..618f0e08 --- /dev/null +++ b/server/marketserver/api/v1/asset/asset.go @@ -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()) + }) +} diff --git a/server/marketserver/api/v1/nft/enter.go b/server/marketserver/api/v1/asset/enter.go similarity index 52% rename from server/marketserver/api/v1/nft/enter.go rename to server/marketserver/api/v1/asset/enter.go index 9c4d0a36..98329ef6 100644 --- a/server/marketserver/api/v1/nft/enter.go +++ b/server/marketserver/api/v1/asset/enter.go @@ -1,5 +1,5 @@ -package nft +package asset type ApiGroup struct { - NftMetaApi + AssetApi } diff --git a/server/marketserver/api/v1/enter.go b/server/marketserver/api/v1/enter.go index 6dc5e6b9..0a5f4d41 100644 --- a/server/marketserver/api/v1/enter.go +++ b/server/marketserver/api/v1/enter.go @@ -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) diff --git a/server/marketserver/api/v1/market/enter.go b/server/marketserver/api/v1/market/enter.go new file mode 100644 index 00000000..02cc7422 --- /dev/null +++ b/server/marketserver/api/v1/market/enter.go @@ -0,0 +1,5 @@ +package market + +type ApiGroup struct { + MarketApi +} diff --git a/server/marketserver/api/v1/market/market.go b/server/marketserver/api/v1/market/market.go new file mode 100644 index 00000000..5fd81a12 --- /dev/null +++ b/server/marketserver/api/v1/market/market.go @@ -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()) + }) +} diff --git a/server/marketserver/api/v1/nft/nftmeta.go b/server/marketserver/api/v1/nft/nftmeta.go deleted file mode 100644 index 87c4f4c3..00000000 --- a/server/marketserver/api/v1/nft/nftmeta.go +++ /dev/null @@ -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) -} diff --git a/server/marketserver/router/asset/asset.go b/server/marketserver/router/asset/asset.go new file mode 100644 index 00000000..34a844a3 --- /dev/null +++ b/server/marketserver/router/asset/asset.go @@ -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) +} diff --git a/server/marketserver/router/nft/enter.go b/server/marketserver/router/asset/enter.go similarity index 51% rename from server/marketserver/router/nft/enter.go rename to server/marketserver/router/asset/enter.go index 16d99281..5fb7e120 100644 --- a/server/marketserver/router/nft/enter.go +++ b/server/marketserver/router/asset/enter.go @@ -1,5 +1,5 @@ -package nft +package asset type RouterGroup struct { - NftMetaRouter + AssetRouter } diff --git a/server/marketserver/router/market/enter.go b/server/marketserver/router/market/enter.go new file mode 100644 index 00000000..5e71f16b --- /dev/null +++ b/server/marketserver/router/market/enter.go @@ -0,0 +1,5 @@ +package market + +type RouterGroup struct { + MarketRouter +} diff --git a/server/marketserver/router/market/market.go b/server/marketserver/router/market/market.go new file mode 100644 index 00000000..544dec21 --- /dev/null +++ b/server/marketserver/router/market/market.go @@ -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) +} diff --git a/server/marketserver/router/nft/nftmeta.go b/server/marketserver/router/nft/nftmeta.go deleted file mode 100644 index 031d919d..00000000 --- a/server/marketserver/router/nft/nftmeta.go +++ /dev/null @@ -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) -} diff --git a/server/marketserver/router/routermgr.go b/server/marketserver/router/routermgr.go index 0e17252b..1afee9fc 100644 --- a/server/marketserver/router/routermgr.go +++ b/server/marketserver/router/routermgr.go @@ -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")