// this file is auto create by program, don't edit manually package data import ( mhayaError "github.com/mhaya/error" mhayaLogger "github.com/mhaya/logger" ) type drawConfig struct { maps map[int]*drawConfigRow } type drawConfigRow struct { ID int // #规则ID Type int // 规则类型(1新手2基础) Order int // 顺序 Weight int // 权重 Reward []ItemReward // 奖励信息 HourTotalCondition int // 每小时最多中奖次数条件 DailyTotalCondition int // 每天最多中奖次数 WeeklyTotalCondition int // 每周最多中奖次数 PersonTotalCondition int // 个人最多中奖次数条件 } func (p *drawConfig) Name() string { return "drawConfig" } func (p *drawConfig) Init() { p.maps = make(map[int]*drawConfigRow) } func (p *drawConfig) OnLoad(maps interface{}, _ bool) (int, error) { list, ok := maps.([]interface{}) if !ok { return 0, mhayaError.Error("maps convert to []interface{} error.") } loadMaps := make(map[int]*drawConfigRow) for index, data := range list { loadConfig := &drawConfigRow{} err := DecodeData(data, loadConfig) if err != nil { mhayaLogger.Warnf("decode error. [row = %d, %v], err = %s", index+1, loadConfig, err) continue } loadMaps[loadConfig.ID] = loadConfig } p.maps = loadMaps return len(list), nil } func (p *drawConfig) OnAfterLoad(_ bool) { } func (p *drawConfig) Get(pk int) (*drawConfigRow, bool) { i, found := p.maps[pk] return i, found } func (p *drawConfig) Contain(pk int) bool { _, found := p.Get(pk) return found }