diff --git a/server/marketserver/api/v1/enter.go b/server/marketserver/api/v1/enter.go index f8bc6bff..7a569858 100644 --- a/server/marketserver/api/v1/enter.go +++ b/server/marketserver/api/v1/enter.go @@ -1,27 +1,29 @@ package v1 import ( - "main/api/v1/market" - "main/api/v1/asset" - "main/api/v1/hero" - "main/api/v1/gold_bullion" - "main/api/v1/shopcart" - "main/api/v1/nft" - "main/api/v1/ingame" - "main/api/v1/user" "main/api/v1/activity" + "main/api/v1/asset" + "main/api/v1/event" + "main/api/v1/gold_bullion" + "main/api/v1/hero" + "main/api/v1/ingame" + "main/api/v1/market" + "main/api/v1/nft" + "main/api/v1/shopcart" + "main/api/v1/user" ) type ApiGroup struct { - MarketApiGroup market.ApiGroup - AssetApiGroup asset.ApiGroup - HeroApiGroup hero.ApiGroup + MarketApiGroup market.ApiGroup + AssetApiGroup asset.ApiGroup + HeroApiGroup hero.ApiGroup GoldBullionApiGroup gold_bullion.ApiGroup - ShopCartApiGroup shopcart.ApiGroup - NftApiGroup nft.ApiGroup - InGameApiGroup ingame.ApiGroup - UserApiGroup user.ApiGroup - ActivityApiGroup activity.ApiGroup + ShopCartApiGroup shopcart.ApiGroup + NftApiGroup nft.ApiGroup + InGameApiGroup ingame.ApiGroup + UserApiGroup user.ApiGroup + ActivityApiGroup activity.ApiGroup + EventApiGroup event.ApiGroup } var ApiGroupApp = new(ApiGroup) diff --git a/server/marketserver/api/v1/event/enter.go b/server/marketserver/api/v1/event/enter.go new file mode 100644 index 00000000..5124f6fa --- /dev/null +++ b/server/marketserver/api/v1/event/enter.go @@ -0,0 +1,5 @@ +package event + +type ApiGroup struct { + EventApi +} diff --git a/server/marketserver/api/v1/event/event.go b/server/marketserver/api/v1/event/event.go new file mode 100644 index 00000000..bb8abc85 --- /dev/null +++ b/server/marketserver/api/v1/event/event.go @@ -0,0 +1,48 @@ +package event + +import ( + "f5" + "fmt" + "marketserver/constant" + "q5" + "strings" + + "github.com/gin-gonic/gin" +) + +type EventApi struct { +} + +func (ea *EventApi) TxQuery(c *gin.Context) { + netid := q5.SafeToInt32(c.Param("net_id")) + txhash := strings.ToLower(c.Param("txhash")) + + rspObj := struct { + ErrCode int32 `json:"errcode"` + ErrMsg string `json:"errmsg"` + Confirmed int32 `json:"confirmed"` + }{} + + { + sql := fmt.Sprintf(`SELECT idx FROM t_blockchain_event WHERE idx > 0 AND txhash = ? AND net_id = %d`, netid) + params := []string{ + txhash, + } + f5.GetGoStyleDb().RawQuery( + constant.BCEVENT_DB, + sql, + params, + func(err error, ds *f5.DataSet) { + if err != nil { + c.JSON(200, rspObj) + return + } + + if ds != nil { + rspObj.Confirmed = 1 + } + + c.JSON(200, rspObj) + }) + } +} diff --git a/server/marketserver/router/event/enter.go b/server/marketserver/router/event/enter.go new file mode 100644 index 00000000..d5d44f6f --- /dev/null +++ b/server/marketserver/router/event/enter.go @@ -0,0 +1,5 @@ +package event + +type RouterGroup struct { + EventRouter +} diff --git a/server/marketserver/router/event/event.go b/server/marketserver/router/event/event.go new file mode 100644 index 00000000..4cfc47be --- /dev/null +++ b/server/marketserver/router/event/event.go @@ -0,0 +1,13 @@ +package event + +import ( + "f5" + v1 "main/api/v1" +) + +type EventRouter struct{} + +func (er *EventRouter) InitRouter() { + api := v1.ApiGroupApp.EventApiGroup + f5.GetApp().GetGinEngine().GET("/api/chain/txhash/:net_id/:txhash", api.EventApi.TxQuery) +} diff --git a/server/marketserver/router/routermgr.go b/server/marketserver/router/routermgr.go index 13d63642..cbb43402 100644 --- a/server/marketserver/router/routermgr.go +++ b/server/marketserver/router/routermgr.go @@ -3,27 +3,29 @@ package router import ( "f5" "main/middleware" - "main/router/market" - "main/router/asset" - "main/router/hero" - "main/router/gold_bullion" - "main/router/shopcart" - "main/router/nft" - "main/router/ingame" - "main/router/user" "main/router/activity" + "main/router/asset" + "main/router/gold_bullion" + "main/router/hero" + "main/router/ingame" + "main/router/market" + "main/router/nft" + "main/router/shopcart" + "main/router/user" + "marketserver/router/event" ) type routerMgr struct { - market market.RouterGroup - asset asset.RouterGroup - hero hero.RouterGroup + market market.RouterGroup + asset asset.RouterGroup + hero hero.RouterGroup goldBullion gold_bullion.RouterGroup - shopCart shopcart.RouterGroup - nft nft.RouterGroup - ingame ingame.RouterGroup - user user.RouterGroup - activity activity.RouterGroup + shopCart shopcart.RouterGroup + nft nft.RouterGroup + ingame ingame.RouterGroup + user user.RouterGroup + activity activity.RouterGroup + event event.RouterGroup } func (this *routerMgr) Init() { @@ -37,6 +39,7 @@ func (this *routerMgr) Init() { this.ingame.IngameRouter.InitRouter() this.user.UserRouter.InitRouter() this.activity.StackingRouter.InitRouter() + this.event.EventRouter.InitRouter() f5.GetSysLog().Info("routerMgr.init")