diff --git a/server/adminserver/api/v1/system/gameswitch.go b/server/adminserver/api/v1/system/gameswitch.go index ec949649..c35b1794 100644 --- a/server/adminserver/api/v1/system/gameswitch.go +++ b/server/adminserver/api/v1/system/gameswitch.go @@ -5,6 +5,7 @@ import ( "fmt" "main/constant" "main/model/system" + "main/mt" "net/http" "q5" @@ -183,6 +184,8 @@ func (this *GameSwitchApi) Edit(c *gin.Context) { "code": 0, "message": "", }) + + this.refreshAct(func(f5.HttpCliResponse) {}) } func (this *GameSwitchApi) Del(c *gin.Context) { @@ -228,3 +231,32 @@ func (this *GameSwitchApi) Del(c *gin.Context) { "message": "", }) } + +func (this *GameSwitchApi) Refresh(c *gin.Context) { + this.refreshAct(func(rsp f5.HttpCliResponse) { + if rsp.GetErr() != nil { + f5.RspErr2(c, 500, rsp.GetErr().Error()) + return + } + rspJson := struct { + ErrCode int32 `json:"errcode"` + ErrMsg string `json:"errmsg"` + CP int32 `json:"contributionPoint"` + }{} + if q5.DecodeJson(rsp.GetRawData(), &rspJson) != nil { + f5.RspErr2(c, 500, "server internal error") + return + } + f5.RspErr2(c, rspJson.ErrCode, rspJson.ErrMsg) + }) +} + +func (this *GameSwitchApi) refreshAct(cb func(f5.HttpCliResponse)) { + f5.GetHttpCliMgr().SendGoStyleRequest( + mt.Table.Config.RandElement().GetGameapiUrl()+"/webapp/index.php", + map[string]string{ + "c": "OutAppTools", + "a": "refreshServerSwitch", + }, + cb) +} diff --git a/server/adminserver/router/system/game_switch.go b/server/adminserver/router/system/game_switch.go index e50e1ffe..7d0ecc59 100644 --- a/server/adminserver/router/system/game_switch.go +++ b/server/adminserver/router/system/game_switch.go @@ -18,6 +18,7 @@ func (this *GameSwitchRoute) InitGameSwitchRouter(priRouter *gin.RouterGroup) { //group.POST("add", middleware.Permission("api/v1/game_switch/add", api.Add)) group.POST("edit", middleware.Permission("api/v1/game_switch/edit", api.Edit)) //group.POST("del", middleware.Permission("api/v1/game_switch/del", api.Del)) - group.GET("list", middleware.Permission("api/v1/game_switch/list", api.List)) + group.GET("list", middleware.Permission("api/v1/game_switch/list", api.List)) + group.GET("refresh", middleware.Permission("api/v1/game_switch/refresh", api.Refresh)) } }