//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

package cfg

import "errors"

type GameCaravanThingData struct {
    Id int32
    Goodsname string
    Goodsinfor string
    Goodsicon string
    Goodsprice int32
    Changeperiod []int32
    PriceChangeWeight []int32
    PriceChangeWeightOne []int32
    PriceChangeWeightTwo []int32
    PriceChangeWeightThree []int32
    FluctuationRange int32
    Pricemin int32
    Pricemax int32
    Goodsnum int32
}

const TypeId_GameCaravanThingData = 638455774

func (*GameCaravanThingData) GetTypeId() int32 {
    return 638455774
}

func (_v *GameCaravanThingData)Deserialize(_buf map[string]interface{}) (err error) {
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id"].(float64); !_ok_ { err = errors.New("id error"); return }; _v.Id = int32(_tempNum_) }
    {var _ok_ bool; var __json_text__ map[string]interface{}; if __json_text__, _ok_ = _buf["goodsname"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.Goodsname error"); return };  { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.Goodsname, _ok_ = __json_text__["text"].(string); !_ok_ { err = errors.New("text error"); return } } }
    {var _ok_ bool; var __json_text__ map[string]interface{}; if __json_text__, _ok_ = _buf["goodsinfor"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.Goodsinfor error"); return };  { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.Goodsinfor, _ok_ = __json_text__["text"].(string); !_ok_ { err = errors.New("text error"); return } } }
    { var _ok_ bool; if _v.Goodsicon, _ok_ = _buf["goodsicon"].(string); !_ok_ { err = errors.New("goodsicon error"); return } }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["goodsprice"].(float64); !_ok_ { err = errors.New("goodsprice error"); return }; _v.Goodsprice = int32(_tempNum_) }
     {
                var _arr_ []interface{}
                var _ok_ bool
                if _arr_, _ok_ = _buf["changeperiod"].([]interface{}); !_ok_ { err = errors.New("changeperiod error"); return }

                _v.Changeperiod = make([]int32, 0, len(_arr_))
                
                for _, _e_ := range _arr_ {
                    var _list_v_ int32
                    { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) }
                    _v.Changeperiod = append(_v.Changeperiod, _list_v_)
                }
            }

     {
                var _arr_ []interface{}
                var _ok_ bool
                if _arr_, _ok_ = _buf["PriceChangeWeight"].([]interface{}); !_ok_ { err = errors.New("PriceChangeWeight error"); return }

                _v.PriceChangeWeight = make([]int32, 0, len(_arr_))
                
                for _, _e_ := range _arr_ {
                    var _list_v_ int32
                    { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) }
                    _v.PriceChangeWeight = append(_v.PriceChangeWeight, _list_v_)
                }
            }

     {
                var _arr_ []interface{}
                var _ok_ bool
                if _arr_, _ok_ = _buf["PriceChangeWeight_one"].([]interface{}); !_ok_ { err = errors.New("PriceChangeWeight_one error"); return }

                _v.PriceChangeWeightOne = make([]int32, 0, len(_arr_))
                
                for _, _e_ := range _arr_ {
                    var _list_v_ int32
                    { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) }
                    _v.PriceChangeWeightOne = append(_v.PriceChangeWeightOne, _list_v_)
                }
            }

     {
                var _arr_ []interface{}
                var _ok_ bool
                if _arr_, _ok_ = _buf["PriceChangeWeight_two"].([]interface{}); !_ok_ { err = errors.New("PriceChangeWeight_two error"); return }

                _v.PriceChangeWeightTwo = make([]int32, 0, len(_arr_))
                
                for _, _e_ := range _arr_ {
                    var _list_v_ int32
                    { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) }
                    _v.PriceChangeWeightTwo = append(_v.PriceChangeWeightTwo, _list_v_)
                }
            }

     {
                var _arr_ []interface{}
                var _ok_ bool
                if _arr_, _ok_ = _buf["PriceChangeWeight_three"].([]interface{}); !_ok_ { err = errors.New("PriceChangeWeight_three error"); return }

                _v.PriceChangeWeightThree = make([]int32, 0, len(_arr_))
                
                for _, _e_ := range _arr_ {
                    var _list_v_ int32
                    { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) }
                    _v.PriceChangeWeightThree = append(_v.PriceChangeWeightThree, _list_v_)
                }
            }

    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["FluctuationRange"].(float64); !_ok_ { err = errors.New("FluctuationRange error"); return }; _v.FluctuationRange = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["pricemin"].(float64); !_ok_ { err = errors.New("pricemin error"); return }; _v.Pricemin = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["pricemax"].(float64); !_ok_ { err = errors.New("pricemax error"); return }; _v.Pricemax = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["goodsnum"].(float64); !_ok_ { err = errors.New("goodsnum error"); return }; _v.Goodsnum = int32(_tempNum_) }
    return
}

func DeserializeGameCaravanThingData(_buf map[string]interface{}) (*GameCaravanThingData, error) {
    v := &GameCaravanThingData{}
    if err := v.Deserialize(_buf); err == nil {
        return v, nil
    } else {
        return nil, err
    }
}
