go_dreamfactory/modules/sys/config.go
2022-09-08 15:49:17 +08:00

48 lines
1.0 KiB
Go

package sys
import (
"fmt"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
cfg "go_dreamfactory/sys/configure/structs"
)
const (
gameOpencond = "game_opencond.json"
)
type configureComp struct {
modules.MCompConfigure
}
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.MCompConfigure.Init(service, module, comp, options)
this.LoadConfigure(gameOpencond, cfg.NewGameOpencond)
return
}
func (this *configureComp) getOpencondCfg() (data *cfg.GameOpencond, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(gameOpencond); err != nil {
return
} else {
if data, ok = v.(*cfg.GameOpencond); !ok {
err = fmt.Errorf("%T no is *cfg.GameOpencond", v)
return
}
}
return
}
func (this *configureComp) getOpencondList() (list []*cfg.GameOpencondData) {
if cfg, err := this.getOpencondCfg(); err != nil {
return nil
} else {
list = cfg.GetDataList()
}
return
}