gameswitch list

This commit is contained in:
yangduo 2024-08-21 14:36:01 +08:00
parent b4780301b9
commit cb0847c3f5
8 changed files with 81 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import (
"main/api/v1/activity"
"main/api/v1/asset"
"main/api/v1/event"
"main/api/v1/game_switch"
"main/api/v1/gold_bullion"
"main/api/v1/hero"
"main/api/v1/ingame"
@ -26,6 +27,7 @@ type ApiGroup struct {
ActivityApiGroup activity.ApiGroup
EventApiGroup event.ApiGroup
RechargeApiGroup recharge.ApiGroup
SwitchApiGroup game_switch.ApiGroup
}
var ApiGroupApp = new(ApiGroup)

View File

@ -0,0 +1,5 @@
package game_switch
type ApiGroup struct {
GameSwitchApi
}

View File

@ -0,0 +1,41 @@
package game_switch
import (
"f5"
"main/constant"
"net/http"
"q5"
"github.com/gin-gonic/gin"
)
type GameSwitchApi struct {
}
func (this *GameSwitchApi) List(c *gin.Context) {
f5.GetGoStyleDb().RawQuery(
constant.CONF_DB,
"SELECT * FROM t_game_switch WHERE 1=1",
[]string{},
func(err error, ds *f5.DataSet) {
if err != nil {
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": err.Error(),
})
return
}
data := map[string]int32{}
for ds.Next() {
data[ds.GetByName("switch_name")] = q5.SafeToInt32(ds.GetByName("is_open"))
}
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "获取成功",
"contributionPoint": "",
"data": data,
})
})
}

View File

@ -97,6 +97,17 @@ func (this *app) registerDataSources() {
1,
mt.Table.AccountDb.GetById(0).GetMaxOpenConns(),
mt.Table.AccountDb.GetById(0).GetMaxIdleConns())
f5.GetGoStyleDb().RegisterDataSource(
constant.CONF_DB,
mt.Table.ConfDb.GetById(0).GetHost(),
mt.Table.ConfDb.GetById(0).GetPort(),
mt.Table.ConfDb.GetById(0).GetUser(),
mt.Table.ConfDb.GetById(0).GetPasswd(),
mt.Table.ConfDb.GetById(0).GetDatabase(),
1,
mt.Table.ConfDb.GetById(0).GetMaxOpenConns(),
mt.Table.ConfDb.GetById(0).GetMaxIdleConns())
}
func (this *app) HasTask() bool {

View File

@ -5,6 +5,7 @@ const (
BCNFT_DB = "bcnftdb"
BCEVENT_DB = "bceventdb"
GAME_DB = "gamedb"
CONF_DB = "confdb"
)
const (

View File

@ -0,0 +1,5 @@
package game_switch
type RouterGroup struct {
GameSwitchRouter
}

View File

@ -0,0 +1,13 @@
package game_switch
import (
"f5"
v1 "main/api/v1"
)
type GameSwitchRouter struct{}
func (this *GameSwitchRouter) InitRouter() {
api := v1.ApiGroupApp.SwitchApiGroup
f5.GetApp().GetGinEngine().GET("/api/server_switch", api.GameSwitchApi.List)
}

View File

@ -6,6 +6,7 @@ import (
"main/router/activity"
"main/router/asset"
"main/router/event"
"main/router/game_switch"
"main/router/gold_bullion"
"main/router/hero"
"main/router/ingame"
@ -28,6 +29,7 @@ type routerMgr struct {
activity activity.RouterGroup
event event.RouterGroup
recharge recharge.RouterGroup
gameswitch game_switch.RouterGroup
}
func (this *routerMgr) Init() {
@ -45,6 +47,7 @@ func (this *routerMgr) Init() {
this.activity.ContributionRouter.InitRouter()
this.event.EventRouter.InitRouter()
this.recharge.RechargeRouter.InitRouter()
this.gameswitch.GameSwitchRouter.InitRouter()
f5.GetSysLog().Info("routerMgr.init")