108 lines
2.6 KiB
Go
108 lines
2.6 KiB
Go
package wps
|
|
|
|
import "fmt"
|
|
|
|
// GetGoodBrand 查询商品的品牌
|
|
func (c *WeiPinShangClient) GetGoodBrand(req GoodBrandReq) (*GoodBrandList, error) {
|
|
param := StructToMapString(req)
|
|
out := GoodBrandRes{}
|
|
err := c.PostAndParse(GetGoodBrandURL, param, &out)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if out.Code != 0 {
|
|
return nil, fmt.Errorf(out.Msg)
|
|
}
|
|
res := out.Data
|
|
return &res, err
|
|
}
|
|
|
|
// GetGoodsClassify 查询商品分类
|
|
func (c *WeiPinShangClient) GetGoodsClassify(req GetGoodsClassifyReq) (*[]GoodsClassify, error) {
|
|
param := StructToMapString(req)
|
|
out := GetGoodsClassifyRes{}
|
|
err := c.PostAndParse(GetGoodsClassifyURL, param, &out)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if out.Code != 0 {
|
|
return nil, fmt.Errorf(out.Msg)
|
|
}
|
|
res := out.Data
|
|
return &res, err
|
|
}
|
|
|
|
// GetGoodsList 获取全部商品列表接口
|
|
func (c *WeiPinShangClient) GetGoodsList(req GetGoodsListReq) (*GetGoodsList, error) {
|
|
param := StructToMapString(req)
|
|
out := GetGoodsListRes{}
|
|
err := c.PostAndParse(GetGoodsListURL, param, &out)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if out.Code != 0 {
|
|
return nil, fmt.Errorf(out.Msg)
|
|
}
|
|
res := out.Data
|
|
return &res, err
|
|
}
|
|
|
|
// GetGoodsdept (推荐使用)获取后台已选商品列表接口
|
|
func (c *WeiPinShangClient) GetGoodsdept(req GetGoodsdeptReq) (*Goodsdept, error) {
|
|
param := StructToMapString(req)
|
|
out := GetGoodsdeptRes{}
|
|
err := c.PostAndParse(GetGoodsdeptURL, param, &out)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if out.Code != 0 {
|
|
return nil, fmt.Errorf(out.Msg)
|
|
}
|
|
res := out.Data
|
|
return &res, err
|
|
}
|
|
|
|
// GetDetailsGoods 获取批量商品详情
|
|
func (c *WeiPinShangClient) GetDetailsGoods(req GetDetailsGoodsReq) (*[]GoodsItem, error) {
|
|
param := StructToMapString(req)
|
|
out := GetDetailsGoodsRes{}
|
|
err := c.PostAndParse(GetDetailsGoodsUrl, param, &out)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if out.Code != 0 {
|
|
return nil, fmt.Errorf(out.Msg)
|
|
}
|
|
res := out.Data
|
|
return &res, err
|
|
}
|
|
|
|
// GetGoodsDetails 获取单个商品详情接口
|
|
func (c *WeiPinShangClient) GetGoodsDetails(req GetGoodsDetailsReq) (*GoodsItem, error) {
|
|
param := StructToMapString(req)
|
|
out := GetGoodsDetailsRes{}
|
|
err := c.PostAndParse(GetGoodsDetailsURL, param, &out)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if out.Code != 0 {
|
|
return nil, fmt.Errorf(out.Msg)
|
|
}
|
|
res := out.Data
|
|
return &res, err
|
|
}
|
|
|
|
func (c *WeiPinShangClient) GetGoodsStock(req GetGoodsStockReq) (*[]GoodsStock, error) {
|
|
param := StructToMapString(req)
|
|
out := GetGoodsStockRes{}
|
|
err := c.PostAndParse(GetGoodsStockURL, param, &out)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if out.Code != 0 {
|
|
return nil, fmt.Errorf(out.Msg)
|
|
}
|
|
res := out.Data
|
|
return &res, err
|
|
}
|