go_dreamfactory/modules/sys/config.go

66 lines
1.4 KiB
Go

package sys
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
cfg "go_dreamfactory/sys/configure/structs"
)
const (
gameOpencond = "game_opencond.json"
)
type configureComp struct {
modules.MCompConfigure
module *ModuleSys
}
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)
this.module = module.(*ModuleSys)
return
}
func (this *configureComp) getOpencondCfg() (data *cfg.GameOpencond, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(gameOpencond); err == nil {
if data, ok = v.(*cfg.GameOpencond); !ok {
err = fmt.Errorf("%T no is *cfg.GameOpencond", v)
return
}
}
return
}
func (this *configureComp) GetOpenCondCfgById(id string) (data *cfg.GameOpencondData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(gameOpencond); err == nil {
if c, ok := v.(*cfg.GameOpencond); ok {
if data = c.Get(id); data != nil {
return
}
}
}
err = comm.NewNotFoundConfErr("opencond", gameOpencond, id)
return
}
func (this *configureComp) getOpencondConf() (list []*cfg.GameOpencondData) {
if cfg, err := this.getOpencondCfg(); err == nil {
list = cfg.GetDataList()
}
return
}