添加淘宝
This commit is contained in:
@@ -10,6 +10,34 @@ import (
|
||||
)
|
||||
|
||||
// GetStoreAllCategory 获取门店所有分类
|
||||
func (a *API) GetStoreAllCategory() ([]*CategoryInfo, error) {
|
||||
// 获取所有的父分类
|
||||
parent, err := a.GetStoreCategoryInfo("")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := make([]*CategoryInfo, 0)
|
||||
for _, v := range parent.ChildCategorys {
|
||||
childNode, err := a.GetStoreCategoryInfo(v.Code)
|
||||
if err != nil || len(childNode.ChildCategorys) == 0 {
|
||||
result = append(result, &CategoryInfo{
|
||||
ChildCategorys: nil,
|
||||
Code: v.Code,
|
||||
Desc: v.Desc,
|
||||
ForestId: v.ForestId,
|
||||
Leaf: v.Leaf,
|
||||
Name: v.Name,
|
||||
ParentForestId: v.ParentForestId,
|
||||
Status: v.Status,
|
||||
})
|
||||
continue
|
||||
}
|
||||
result = append(result, childNode)
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetStoreCategoryInfo 获取门店指定分类
|
||||
func (a *API) GetStoreCategoryInfo(code string) (*CategoryInfo, error) {
|
||||
@@ -29,15 +57,44 @@ func (a *API) GetStoreCategoryInfo(code string) (*CategoryInfo, error) {
|
||||
return info, nil
|
||||
}
|
||||
|
||||
// AddStoreCategoryInfo 添加门店分类
|
||||
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)
|
||||
if !*resp.Result.Success {
|
||||
return "", fmt.Errorf(*resp.Result.ErrMsg)
|
||||
}
|
||||
|
||||
return *resp.Result.Model, nil
|
||||
}
|
||||
|
||||
// DeleteStoreCategoryInfo 删除门店分类
|
||||
func (a *API) DeleteStoreCategoryInfo(param *request.AlibabaWdkSkuCategoryDeleteRequest) error {
|
||||
storeCategory := ability587.NewAbility587(&a.client)
|
||||
resp, err := storeCategory.AlibabaWdkSkuCategoryDelete(param, a.token)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !*resp.Result.Success {
|
||||
return fmt.Errorf(*resp.Result.ErrMsg)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateStoreCategoryInfo 修改门店分类
|
||||
func (a *API) UpdateStoreCategoryInfo(param *request.AlibabaWdkSkuCategoryUpdateRequest) error {
|
||||
storeCategory := ability587.NewAbility587(&a.client)
|
||||
resp, err := storeCategory.AlibabaWdkSkuCategoryUpdate(param, a.token)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !*resp.Result.Success {
|
||||
return fmt.Errorf(*resp.Result.ErrMsg)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user