57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
package passon
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/sys/configure"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
const (
|
|
game_passon = "game_passon.json"
|
|
)
|
|
|
|
// /配置管理基础组件
|
|
type Configure_Comp struct {
|
|
modules.MCompConfigure
|
|
}
|
|
|
|
// 组件初始化接口
|
|
func (this *Configure_Comp) 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(game_passon, cfg.NewGamePasson)
|
|
|
|
return
|
|
}
|
|
|
|
// 加载多个配置文件
|
|
func (this *Configure_Comp) LoadMultiConfigure(confs map[string]interface{}) (err error) {
|
|
for k, v := range confs {
|
|
err = configure.RegisterConfigure(k, v, nil)
|
|
if err != nil {
|
|
log.Errorf("配置文件:%s解析失败!", k)
|
|
break
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *Configure_Comp) GetPassonConf(key int32) (configure *cfg.GamePassonData, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
|
|
if v, err = this.GetConfigure(game_passon); err != nil {
|
|
return
|
|
}
|
|
|
|
if configure, ok = v.(*cfg.GamePasson).GetDataMap()[key]; !ok {
|
|
err = comm.NewNotFoundConfErr(moduleName, game_passon, key)
|
|
return
|
|
}
|
|
return
|
|
}
|