// 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 PlatformConfig struct { maps map[int]*PlatformConfigRow } type PlatformConfigRow struct { ID int // 平台ID Name string // 名称 Enable int // 是否开启(0否1是) } func (p *PlatformConfig) Name() string { return "PlatformConfig" } func (p *PlatformConfig) Init() { p.maps = make(map[int]*PlatformConfigRow) } func (p *PlatformConfig) 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]*PlatformConfigRow) for index, data := range list { loadConfig := &PlatformConfigRow{} 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 *PlatformConfig) OnAfterLoad(_ bool) { } func (p *PlatformConfig) Get(pk int) (*PlatformConfigRow, bool) { i, found := p.maps[pk] return i, found } func (p *PlatformConfig) Contain(pk int) bool { _, found := p.Get(pk) return found }