1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- // 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 itemConfig struct {
- maps map[int]*itemConfigRow
- }
- type itemConfigRow struct {
- ID int // #物品ID
- Type int // 物品类型(1可使用物品2基础物品3wallet4邀请相关)
- ItemKey string // 键名
- }
- func (p *itemConfig) Name() string {
- return "itemConfig"
- }
- func (p *itemConfig) Init() {
- p.maps = make(map[int]*itemConfigRow)
- }
- func (p *itemConfig) 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]*itemConfigRow)
- for index, data := range list {
- loadConfig := &itemConfigRow{}
- 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 *itemConfig) OnAfterLoad(_ bool) {
- }
- func (p *itemConfig) Get(pk int) (*itemConfigRow, bool) {
- i, found := p.maps[pk]
- return i, found
- }
- func (p *itemConfig) Contain(pk int) bool {
- _, found := p.Get(pk)
- return found
- }
|