From 2293cae17524bf8442a1764bade5cd427774fdba Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 19 Mar 2019 22:52:51 +0800 Subject: [PATCH] - make params shopCategoryLevel, sor and username optional for jd.AddShopCategory --- platformapi/jdapi/sku.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/platformapi/jdapi/sku.go b/platformapi/jdapi/sku.go index 09adc8a3..42228100 100644 --- a/platformapi/jdapi/sku.go +++ b/platformapi/jdapi/sku.go @@ -204,11 +204,17 @@ func (a *API) QueryChildCategoriesForOP(pid int64) (catList []*CategoryInfo, err // https://opendj.jd.com/staticnew/widgets/resources.html?groupid=180&apiid=de26f24a62aa47a49e5ab7579d638cb3 func (a *API) AddShopCategory(pid int64, shopCategoryName string, shopCategoryLevel, sort int, userName string) (catId string, err error) { params := map[string]interface{}{ - KeyPID: pid, - KeyShopCategoryName: shopCategoryName, - KeyShopCategoryLevel: shopCategoryLevel, - KeySort: sort, - "createPin": utils.GetAPIOperator(userName), + KeyPID: pid, + KeyShopCategoryName: shopCategoryName, + } + if shopCategoryLevel > 0 { + params[KeyShopCategoryLevel] = shopCategoryLevel + } + if sort >= 0 { + params[KeySort] = sort + } + if userName != "" { + params["createPin"] = utils.GetAPIOperator(userName) } result, err := a.AccessAPINoPage("pms/addShopCategory", params, nil, nil, nil) if err == nil {