This commit is contained in:
aozhiwei 2024-08-30 16:32:24 +08:00
commit a8c104912a
2 changed files with 34 additions and 1 deletions

View File

@ -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)
}

View File

@ -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))
}
}