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

package pposRequest

import (
	"errors"
	"net/url"
)

//new...
func (that *PPOSClient) NewBusinessGetByIds() *BusinessGetByIdsRequest {
	return &BusinessGetByIdsRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/base/business/getByIds",
		},
	}
}

//Response...
type BusinessGetByIdsResponse struct {
	BusinessId      int64  `json:"business_id"`
	BusinessName    string `json:"business_name"`
	BusinessStatus  int64  `json:"business_status"`
	BusinessType    int64  `json:"business_type"`
	BusinessLogo    string `json:"business_logo"`
	BusinessHost    string `json:"business_host"`
	Linkman         string `json:"linkman"`
	Telephone       string `json:"telephone"`
	ProvinceId      int64  `json:"province_id"`
	CityId          int64  `json:"city_id"`
	CountyId        int64  `json:"county_id"`
	CompanyId       int64  `json:"company_id"`
	Address         string `json:"address"`
	Tag             string `json:"tag"`
	StadiumMaxcount int64  `json:"stadium_maxcount"`
	BeginEffective  string `json:"begin_effective"`
	EndEffective    string `json:"end_effective"`
	Description     string `json:"description"`
	SmsNumber       int64  `json:"sms_number"`
	UseBusiness     string `json:"use_business"`
}

//Request...
type BusinessGetByIdsRequest struct {
	Request
}

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

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

//Do ...
func (that *BusinessGetByIdsRequest) Do() ([]*BusinessGetByIdsResponse, 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 := []*BusinessGetByIdsResponse{}
	for _, _v := range _sliceData {
		_vData, _ok := _v.(map[string]interface{})
		if !_ok {
			return nil, errors.New(that.apiAddress + "请求响应格式不正确2")
		}
		_tmp := new(BusinessGetByIdsResponse)
		if _err := that.ParseResponeMp(_tmp, _vData, false); _err != nil {
			return nil, errors.New(that.apiAddress + "请求响应格式化异常:" + _err.Error())
		}
		_rs = append(_rs, _tmp)
	}
	return _rs, nil
}
