// 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 RuleConfig struct { maps map[int]*RuleConfigRow } type RuleConfigRow struct { ID int // ID Num int // 注册人数 MaxTime int // 过期时间(按天) } func (p *RuleConfig) Name() string { return "RuleConfig" } func (p *RuleConfig) Init() { p.maps = make(map[int]*RuleConfigRow) } func (p *RuleConfig) 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]*RuleConfigRow) for index, data := range list { loadConfig := &RuleConfigRow{} 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 *RuleConfig) OnAfterLoad(_ bool) { } func (p *RuleConfig) Get(pk int) (*RuleConfigRow, bool) { i, found := p.maps[pk] return i, found } func (p *RuleConfig) Contain(pk int) bool { _, found := p.Get(pk) return found }