go_dreamfactory/modules/venture/configure.go

66 lines
1.8 KiB
Go

package venture
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
)
const (
game_venturegiflogin = "game_venturegiftslogin.json"
game_venturegiftslvaward = "game_venturegiftslvaward.json"
)
type configureComp struct {
modules.MCompConfigure
module *Venture
}
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.module = module.(*Venture)
err = this.LoadMultiConfigure(map[string]interface{}{
game_venturegiflogin: cfg.NewGameVenturegiftsLogin,
game_venturegiftslvaward: cfg.NewGameVenturegiftsLvaward,
})
return
}
//读取配置数据
func (this *configureComp) GetConfigure(name string) (v interface{}, err error) {
return configure.GetConfigure(name)
}
func (this *configureComp) getGameVenturegiftsLogin(id int32) (conf *cfg.GameVenturegiftsLoginData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(game_venturegiflogin); err != nil {
return
}
if conf, ok = v.(*cfg.GameVenturegiftsLogin).GetDataMap()[id]; !ok {
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_venturegiflogin, id)
this.module.Errorln(err)
return
}
return
}
func (this *configureComp) getGameVenturegiftsLvReward(id int32) (conf *cfg.GameVenturegiftsLvawardData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(game_venturegiftslvaward); err != nil {
return
}
if conf, ok = v.(*cfg.GameVenturegiftsLvaward).GetDataMap()[id]; !ok {
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_venturegiftslvaward, id)
this.module.Errorln(err)
return
}
return
}