/**
 * 核心服务接口sdk（golang版）
 *
 * @desc 啪啪运动 核心服务接口sdk
 * ---------------------------------------------------------------------
 * @author		unphp <unphp@qq.com>
 * @date		2018-12-18
 * @copyright	core-utils
 * ---------------------------------------------------------------------
 */

package pposRequest

import (
	"errors"
	"net/url"
)

//new...
func (that *PPOSClient) NewStadiumGetByIds() *StadiumGetByIdsRequest {
	return &StadiumGetByIdsRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/base/stadium/getByIds",
		},
	}
}

//Response...
type StadiumGetByIdsResponse struct {
	StadiumId   int64  `json:"stadium_id"`
	BusinessId  int64  `json:"business_id"`
	StadiumName string `json:"stadium_name"`
	Logo        string `json:"logo"`
	Images      string `json:"images"`
	Des         string `json:"des"`
	Device      string `json:"device"`
	Telephone   string `json:"telephone"`
	ProvinceId  string `json:"province_id"`
	CityId      string `json:"city_id"`
	CountyId    string `json:"county_id"`
	Latitude    string `json:"latitude"`
	Longitude   string `json:"longitude"`
	Address     string `json:"address"`
	StartTime   string `json:"start_time"`
	EndTime     string `json:"end_time"`
	Status      string `json:"status"`
	Operator    string `json:"operator"`
}

//Request...
type StadiumGetByIdsRequest struct {
	Request
}

func (that *StadiumGetByIdsRequest) SetIds(value string) *StadiumGetByIdsRequest {
	that.initParams()
	that.params.Set("ids", value) //场馆信息获取通过ids
	return that
}
func (that *StadiumGetByIdsRequest) SetColumn(value string) *StadiumGetByIdsRequest {
	that.initParams()
	that.params.Set("column", value) //字段名，逗号隔开
	return that
}

//Params ...
func (that *StadiumGetByIdsRequest) Params() (url.Values, error) {
	that.initParams()
	_params := that.params
	return _params, nil
}

//Do ...
func (that *StadiumGetByIdsRequest) Do() ([]*StadiumGetByIdsResponse, error) {
	//
	_data, _err := that.Client.GetData(that.apiAddress, that)
	if _err != nil {
		return nil, _err
	}
	//
	_sliceData, _ok := _data.([]interface{})
	if !_ok {
		return nil, errors.New(that.apiAddress + "请求响应格式不正确")
	}
	_rs := []*StadiumGetByIdsResponse{}
	for _, _v := range _sliceData {
		_vData, _ok := _v.(map[string]interface{})
		if !_ok {
			return nil, errors.New(that.apiAddress + "请求响应格式不正确2")
		}
		_tmp := new(StadiumGetByIdsResponse)
		if _err := that.ParseResponeMp(_tmp, _vData, false); _err != nil {
			return nil, errors.New(that.apiAddress + "请求响应格式化异常:" + _err.Error())
		}
		_rs = append(_rs, _tmp)
	}
	return _rs, nil
}
