2024-08-27 14:11:23 +08:00

53 lines
848 B
Go

package service
import (
"f5"
"marketserver/constant"
"q5"
)
type gameSwitch struct {
data map[string]int32
time int64
}
func (this *gameSwitch) init() {
this.GetSwitchList()
}
func (this *gameSwitch) unInit() {
}
func (this *gameSwitch) GetSwitchList() map[string]int32 {
now := f5.GetApp().GetRealSeconds()
if now > this.time+30 {
this.data = map[string]int32{}
this.time = now
f5.GetGoStyleDb().RawQuery(
constant.CONF_DB,
"SELECT * FROM t_game_switch WHERE 1=1",
[]string{},
func(err error, ds *f5.DataSet) {
if err != nil {
return
}
for ds.Next() {
this.data[ds.GetByName("switch_name")] = q5.SafeToInt32(ds.GetByName("is_open"))
}
})
}
return this.data
}
func (this *gameSwitch) CheckSwitch(gs string) int32 {
v, exist := this.data[gs]
if exist {
return v
}
return 0
}