123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- // 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
- }
- func (p *itemConfig) GetMap() map[int]*ItemConfigRow {
- return p.maps
- }
|