// 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 contryConfig struct { maps map[int]*ContryConfigRow } type ContryConfigRow struct { ID int // #物品ID NameI string // 国家缩写 NameII string // 英文名 Icon_flag string // 道具icon } func (p *contryConfig) Name() string { return "contryConfig" } func (p *contryConfig) Init() { p.maps = make(map[int]*ContryConfigRow) } func (p *contryConfig) 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]*ContryConfigRow) for index, data := range list { loadConfig := &ContryConfigRow{} 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 *contryConfig) OnAfterLoad(_ bool) { } func (p *contryConfig) Get(pk int) (*ContryConfigRow, bool) { i, found := p.maps[pk] return i, found } func (p *contryConfig) GetAll() map[int]*ContryConfigRow { var ret = make(map[int]*ContryConfigRow) for _, v := range p.maps { ret[v.ID] = v } return ret } func (p *contryConfig) Contain(pk int) bool { _, found := p.Get(pk) return found }