44 lines
1.4 KiB
Go
44 lines
1.4 KiB
Go
package tao_vegetable
|
|
|
|
import (
|
|
"encoding/json"
|
|
"git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability587"
|
|
"git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability587/domain"
|
|
"git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability587/request"
|
|
|
|
"fmt"
|
|
)
|
|
|
|
// GetStoreAllCategory 获取门店所有分类
|
|
|
|
// GetStoreCategoryInfo 获取门店指定分类
|
|
func (a *API) GetStoreCategoryInfo(code string) (*CategoryInfo, error) {
|
|
storeCategory := ability587.NewAbility587(&a.client)
|
|
resp, err := storeCategory.AlibabaWdkSkuCategoryQuery(&request.AlibabaWdkSkuCategoryQueryRequest{Param: &domain.AlibabaWdkSkuCategoryQueryCategoryDo{Code: &code}}, a.token)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if resp.Result.ErrMsg != nil {
|
|
return nil, fmt.Errorf("requestId:" + resp.RequestId + "msg:" + *resp.Result.ErrMsg)
|
|
}
|
|
var info *CategoryInfo
|
|
if err := json.Unmarshal([]byte(*resp.Result.Model), &info); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return info, nil
|
|
}
|
|
|
|
func (a *API) AddStoreCategoryInfo(param *request.AlibabaWdkSkuCategoryAddRequest) (string, error) {
|
|
storeCategory := ability587.NewAbility587(&a.client)
|
|
resp, err := storeCategory.AlibabaWdkSkuCategoryAdd(param, a.token)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
if resp.Result.ErrMsg != nil {
|
|
return "", fmt.Errorf("requestId:" + resp.RequestId + "msg:" + *resp.Result.ErrMsg)
|
|
}
|
|
|
|
return *resp.Result.Model, nil
|
|
}
|