diff --git a/client/client.go b/client/client.go index 0fe95e9..a9531bd 100644 --- a/client/client.go +++ b/client/client.go @@ -1,6 +1,7 @@ package client import ( + "errors" "fmt" "git.oa00.com/supply-chain/service/config" "github.com/smallnest/rpcx/client" @@ -23,7 +24,7 @@ func init() { } // GetClient @Title 获取RPC客户的 -func GetClient(s interface{}) client.XClient { +func GetClient(s interface{}) (client.XClient, error) { path := strings.TrimPrefix(reflect.ValueOf(s).Elem().Type().PkgPath(), basePkgPath) actionName := reflect.ValueOf(s).Elem().Type().Name() key := path + "/" + actionName @@ -38,8 +39,7 @@ func GetClient(s interface{}) client.XClient { d, err := client.NewConsulDiscovery(basePath, servicePath, config.RpcConfig.RegistryServer, nil) if err != nil { - log.Println(err) - return nil + return nil, errors.New("系统异常") } option := client.DefaultOption option.Retries = 3 @@ -51,11 +51,11 @@ func GetClient(s interface{}) client.XClient { } mutex.Unlock() } - return xClient.(client.XClient) + return xClient.(client.XClient), nil } // GetClientName @Title 根据服务名获取客户端 -func GetClientName(base, service string) client.XClient { +func GetClientName(base, service string) (client.XClient, error) { key := fmt.Sprintf("%s/%s", base, service) xClient, ok := mClient.Load(key) if !ok { @@ -65,7 +65,7 @@ func GetClientName(base, service string) client.XClient { d, err := client.NewConsulDiscovery(base, service, config.RpcConfig.RegistryServer, nil) if err != nil { log.Println(err) - return nil + return nil, errors.New("系统异常") } option := client.DefaultOption option.Retries = 3 @@ -77,5 +77,5 @@ func GetClientName(base, service string) client.XClient { } mutex.Unlock() } - return xClient.(client.XClient) + return xClient.(client.XClient), nil } diff --git a/customer/service/audit.go b/customer/service/audit.go index 27ee3c6..bb7bd49 100644 --- a/customer/service/audit.go +++ b/customer/service/audit.go @@ -34,6 +34,10 @@ type ReplyAuditLists struct { // Lists @Title 服务审核列表 func (a *audit) Lists(ctx context.Context, args ArgsAuditLists) (reply ReplyAuditLists, err error) { - err = client.GetClient(a).Call(ctx, "Lists", args, &reply) + xClient, err := client.GetClient(a) + if err != nil { + return + } + err = xClient.Call(ctx, "Lists", args, &reply) return } diff --git a/customer/service/audit/supply.go b/customer/service/audit/supply.go index 64c7891..821f006 100644 --- a/customer/service/audit/supply.go +++ b/customer/service/audit/supply.go @@ -19,7 +19,11 @@ type ArgsSupplyApply struct { // Apply @Title 申请 func (s *supply) Apply(ctx context.Context, args ArgsSupplyApply) error { reply := 0 - return client.GetClient(s).Call(ctx, "Apply", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Apply", args, &reply) } type ArgsSupplyAdopt struct { @@ -30,7 +34,11 @@ type ArgsSupplyAdopt struct { // Adopt @Title 审核通过 func (s *supply) Adopt(ctx context.Context, args ArgsSupplyAdopt) error { reply := 0 - return client.GetClient(s).Call(ctx, "Adopt", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Adopt", args, &reply) } type ArgsSupplyReject struct { @@ -42,7 +50,11 @@ type ArgsSupplyReject struct { // Reject @Title 驳回 func (s *supply) Reject(ctx context.Context, args ArgsSupplyReject) error { reply := 0 - return client.GetClient(s).Call(ctx, "Reject", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Reject", args, &reply) } type ReplySupplyInfo struct { @@ -63,6 +75,10 @@ type ReplySupplyInfo struct { // Info @Title 详情 func (s *supply) Info(ctx context.Context, userServiceId uint) (reply ReplySupplyInfo, err error) { - err = client.GetClient(s).Call(ctx, "Info", userServiceId, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "Info", userServiceId, &reply) return } diff --git a/customer/user.go b/customer/user.go index 1278a5e..92fd31e 100644 --- a/customer/user.go +++ b/customer/user.go @@ -46,7 +46,11 @@ type ReplyUserList struct { // Lists @Title 获取客户列表 func (u *user) Lists(ctx context.Context, args ArgsUserList) (reply ReplyUserList, err error) { - err = client.GetClient(u).Call(ctx, "Lists", args, &reply) + xClient, err := client.GetClient(u) + if err != nil { + return + } + err = xClient.Call(ctx, "Lists", args, &reply) return } @@ -63,7 +67,11 @@ type ArgsUserAdd struct { // Add @Title 添加客户 func (u *user) Add(ctx context.Context, args ArgsUserAdd) error { reply := 0 - return client.GetClient(u).Call(ctx, "Add", args, &reply) + xClient, err := client.GetClient(u) + if err != nil { + return err + } + return xClient.Call(ctx, "Add", args, &reply) } type ReplyUserInfo struct { @@ -76,7 +84,11 @@ type ReplyUserInfo struct { // Info @Title 客户详情 func (u *user) Info(ctx context.Context, userId uint) (result ReplyUserInfo, err error) { - err = client.GetClient(u).Call(ctx, "Info", userId, &result) + xClient, err := client.GetClient(u) + if err != nil { + return + } + err = xClient.Call(ctx, "Info", userId, &result) return } @@ -91,19 +103,31 @@ type ArgsUserEdit struct { // Edit @Title 编辑客户 func (u *user) Edit(ctx context.Context, args ArgsUserEdit) error { reply := 0 - return client.GetClient(u).Call(ctx, "Edit", args, &reply) + xClient, err := client.GetClient(u) + if err != nil { + return err + } + return xClient.Call(ctx, "Edit", args, &reply) } // Enable @Title 启用 func (u *user) Enable(ctx context.Context, userId uint) error { reply := 0 - return client.GetClient(u).Call(ctx, "Enable", userId, &reply) + xClient, err := client.GetClient(u) + if err != nil { + return err + } + return xClient.Call(ctx, "Enable", userId, &reply) } // Disable @Title 停用 func (u *user) Disable(ctx context.Context, userId uint) error { reply := 0 - return client.GetClient(u).Call(ctx, "Disable", userId, &reply) + xClient, err := client.GetClient(u) + if err != nil { + return err + } + return xClient.Call(ctx, "Disable", userId, &reply) } type ArgsUserServiceInfo struct { @@ -118,6 +142,10 @@ type ReplyUserServiceInfo struct { // ServiceInfo @Title 获取服务信息 func (u *user) ServiceInfo(ctx context.Context, args ArgsUserServiceInfo) (reply ReplyUserServiceInfo, err error) { - err = client.GetClient(u).Call(ctx, "ServiceInfo", args, &reply) + xClient, err := client.GetClient(u) + if err != nil { + return + } + err = xClient.Call(ctx, "ServiceInfo", args, &reply) return } diff --git a/customer/user/deposit.go b/customer/user/deposit.go index 9501065..6f6419f 100644 --- a/customer/user/deposit.go +++ b/customer/user/deposit.go @@ -31,7 +31,11 @@ type ArgsDepositAdd struct { // Add @Title 充值 func (d *deposit) Add(ctx context.Context, args ArgsDepositAdd) error { reply := 0 - return client.GetClient(d).Call(ctx, "Add", args, &reply) + xClient, err := client.GetClient(d) + if err != nil { + return err + } + return xClient.Call(ctx, "Add", args, &reply) } type ArgsDepositInfo struct { @@ -57,6 +61,10 @@ type ReplyDepositInfo struct { // Info @Title 详情 func (d *deposit) Info(ctx context.Context, args ArgsDepositInfo) (reply ReplyDepositInfo, err error) { - err = client.GetClient(d).Call(ctx, "Info", args, &reply) + xClient, err := client.GetClient(d) + if err != nil { + return + } + err = xClient.Call(ctx, "Info", args, &reply) return } diff --git a/customer/user/depositAudit.go b/customer/user/depositAudit.go index 21e28c4..1af29f5 100644 --- a/customer/user/depositAudit.go +++ b/customer/user/depositAudit.go @@ -41,7 +41,11 @@ type DepositAuditItem struct { // Lists @Title 充值审核列表 func (d *depositAudit) Lists(ctx context.Context, args ArgsDepositAuditLists) (reply ReplyDepositAuditList, err error) { - err = client.GetClient(d).Call(ctx, "Lists", args, &reply) + xClient, err := client.GetClient(d) + if err != nil { + return + } + err = xClient.Call(ctx, "Lists", args, &reply) return } @@ -53,7 +57,11 @@ type ArgsDepositAuditAdopt struct { // Adopt @Title 通过 func (d *depositAudit) Adopt(ctx context.Context, args ArgsDepositAuditAdopt) error { reply := 0 - return client.GetClient(d).Call(ctx, "Adopt", args, &reply) + xClient, err := client.GetClient(d) + if err != nil { + return err + } + return xClient.Call(ctx, "Adopt", args, &reply) } @@ -66,5 +74,9 @@ type ArgsDepositAuditReject struct { // Reject @Title 驳回 func (d *depositAudit) Reject(ctx context.Context, args ArgsDepositAuditReject) error { reply := 0 - return client.GetClient(d).Call(ctx, "Reject", args, &reply) + xClient, err := client.GetClient(d) + if err != nil { + return err + } + return xClient.Call(ctx, "Reject", args, &reply) } diff --git a/customer/user/wallet.go b/customer/user/wallet.go index 04aa620..1136b89 100644 --- a/customer/user/wallet.go +++ b/customer/user/wallet.go @@ -30,5 +30,9 @@ type ArgsWalletDirect struct { // Direct @Title 直接消费 func (w *wallet) Direct(ctx context.Context, args ArgsDepositAuditReject) error { reply := 0 - return client.GetClient(w).Call(ctx, "Direct", args, &reply) + xClient, err := client.GetClient(w) + if err != nil { + return err + } + return xClient.Call(ctx, "Direct", args, &reply) } diff --git a/jd/brand.go b/jd/brand.go index f8366f1..3ad00d1 100644 --- a/jd/brand.go +++ b/jd/brand.go @@ -25,7 +25,11 @@ type ReplyBrandList struct { // Lists @Title 获取品牌匹配列表 func (b *brand) Lists(ctx context.Context, args ArgsBrandList) (reply ReplyBrandList, err error) { - err = client.GetClient(b).Call(ctx, "Lists", args, &reply) + xClient, err := client.GetClient(b) + if err != nil { + return + } + err = xClient.Call(ctx, "Lists", args, &reply) return } @@ -38,7 +42,11 @@ type ArgsBrandEdit struct { // Edit @Title 编辑品牌匹配 func (b *brand) Edit(ctx context.Context, args ArgsBrandEdit) error { reply := 0 - return client.GetClient(b).Call(ctx, "Edit", args, &reply) + xClient, err := client.GetClient(b) + if err != nil { + return err + } + return xClient.Call(ctx, "Edit", args, &reply) } type ArgsImport struct { @@ -48,5 +56,9 @@ type ArgsImport struct { func (b *brand) Import(ctx context.Context, args []ArgsImport) error { reply := 0 - return client.GetClient(b).Call(ctx, "Import", args, &reply) + xClient, err := client.GetClient(b) + if err != nil { + return err + } + return xClient.Call(ctx, "Import", args, &reply) } diff --git a/jd/category.go b/jd/category.go index 8b0fd20..2aad24d 100644 --- a/jd/category.go +++ b/jd/category.go @@ -27,7 +27,11 @@ type ReplyCategoryList struct { // Lists @Title 获取品牌匹配列表 func (c *category) Lists(ctx context.Context, args ArgsCategoryList) (reply ReplyCategoryList, err error) { - err = client.GetClient(c).Call(ctx, "Lists", args, &reply) + xClient, err := client.GetClient(c) + if err != nil { + return + } + err = xClient.Call(ctx, "Lists", args, &reply) return } @@ -42,12 +46,20 @@ type ArgsCategoryEdit struct { // Edit @Title 编辑品牌匹配 func (c *category) Edit(ctx context.Context, args ArgsCategoryEdit) error { reply := 0 - return client.GetClient(c).Call(ctx, "Edit", args, &reply) + xClient, err := client.GetClient(c) + if err != nil { + return err + } + return xClient.Call(ctx, "Edit", args, &reply) } // Select @Title 类目筛选 func (c *category) Select(ctx context.Context) (reply []CategoryItem, err error) { args := 0 - err = client.GetClient(c).Call(ctx, "Select", args, &reply) + xClient, err := client.GetClient(c) + if err != nil { + return + } + err = xClient.Call(ctx, "Select", args, &reply) return } diff --git a/jd/sku.go b/jd/sku.go index e905ef3..b40e03d 100644 --- a/jd/sku.go +++ b/jd/sku.go @@ -61,14 +61,22 @@ type ReplySkuList struct { // Lists @Title 获取商品列表 func (s *sku) Lists(ctx context.Context, args ArgsSkuList) (reply ReplySkuList, err error) { - err = client.GetClient(s).Call(ctx, "Lists", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "Lists", args, &reply) return } // Start @Title 开始处理 func (s *sku) Start(ctx context.Context, skuIds []uint) error { reply := 0 - return client.GetClient(s).Call(ctx, "Start", skuIds, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Start", skuIds, &reply) } type ReplySkuInfo struct { @@ -103,7 +111,11 @@ type SkuImg struct { // GetImgs @Title 获取预览图 func (s *sku) GetImgs(ctx context.Context, skuId uint) (reply []SkuImg, err error) { - err = client.GetClient(s).Call(ctx, "GetImgs", skuId, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "GetImgs", skuId, &reply) return } @@ -119,7 +131,11 @@ type SkuAttribute struct { // Info @Title 获取商品详情 func (s *sku) Info(ctx context.Context, skuId uint) (reply ReplySkuInfo, err error) { - err = client.GetClient(s).Call(ctx, "Info", skuId, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "Info", skuId, &reply) return } @@ -139,13 +155,21 @@ type SkuImgEdit struct { // Edit @Title 商品编辑 func (s *sku) Edit(ctx context.Context, args ArgsSkuEdit) error { reply := 0 - return client.GetClient(s).Call(ctx, "Edit", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Edit", args, &reply) } // Discard @Title 废弃 func (s *sku) Discard(ctx context.Context, skuIds []uint) error { reply := 0 - return client.GetClient(s).Call(ctx, "Discard", skuIds, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Discard", skuIds, &reply) } type AdoptItem struct { @@ -157,6 +181,10 @@ type AdoptItem struct { // Adopt @Title 入库 func (s *sku) Adopt(ctx context.Context, skuIds []uint) (reply []AdoptItem, err error) { - err = client.GetClient(s).Call(ctx, "Adopt", skuIds, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "Adopt", skuIds, &reply) return } diff --git a/jd/task.go b/jd/task.go index 802a463..5a3b0a6 100644 --- a/jd/task.go +++ b/jd/task.go @@ -11,11 +11,19 @@ type task struct { // PullSku @Title 拉取京东商品 func (t *task) PullSku(ctx context.Context) error { a := 0 - return client.GetClient(t).Call(ctx, "PullSku", 0, &a) + xClient, err := client.GetClient(t) + if err != nil { + return err + } + return xClient.Call(ctx, "PullSku", 0, &a) } // SkuAdd @Title 添加商品到库 func (t *task) SkuAdd(ctx context.Context) error { a := 0 - return client.GetClient(t).Call(ctx, "SkuAdd", 0, &a) + xClient, err := client.GetClient(t) + if err != nil { + return err + } + return xClient.Call(ctx, "SkuAdd", 0, &a) } diff --git a/supply/brand.go b/supply/brand.go index b4054d6..d4516ff 100644 --- a/supply/brand.go +++ b/supply/brand.go @@ -31,13 +31,21 @@ type BrandSearch struct { // Lists @Title 品牌列表 func (b *brand) Lists(ctx context.Context, args ArgsBrandList) (result ReplyBrandList, err error) { - err = client.GetClient(b).Call(ctx, "Lists", args, &result) + xClient, err := client.GetClient(b) + if err != nil { + return + } + err = xClient.Call(ctx, "Lists", args, &result) return } // All @Title 全部品牌 func (b *brand) All(ctx context.Context) (result []BrandItem, err error) { - err = client.GetClient(b).Call(ctx, "All", 0, &result) + xClient, err := client.GetClient(b) + if err != nil { + return + } + err = xClient.Call(ctx, "All", 0, &result) return } @@ -48,7 +56,11 @@ type ArgsBrandAdd struct { // Add @Title 添加品牌 func (b *brand) Add(ctx context.Context, args ArgsBrandAdd) (err error) { reply := 0 - return client.GetClient(b).Call(ctx, "Add", args, &reply) + xClient, err := client.GetClient(b) + if err != nil { + return err + } + return xClient.Call(ctx, "Add", args, &reply) } type ArgsBrandEdit struct { @@ -59,7 +71,11 @@ type ArgsBrandEdit struct { // Edit @Title 编辑品牌 func (b *brand) Edit(ctx context.Context, args ArgsBrandEdit) (err error) { reply := 0 - return client.GetClient(b).Call(ctx, "Edit", args, &reply) + xClient, err := client.GetClient(b) + if err != nil { + return err + } + return xClient.Call(ctx, "Edit", args, &reply) } type ArgsBrandFindByIds struct { @@ -68,6 +84,10 @@ type ArgsBrandFindByIds struct { // FindByIds @Title 品牌获取 func (b *brand) FindByIds(ctx context.Context, args ArgsBrandFindByIds) (result []BrandItem, err error) { - err = client.GetClient(b).Call(ctx, "FindByIds", args, &result) + xClient, err := client.GetClient(b) + if err != nil { + return + } + err = xClient.Call(ctx, "FindByIds", args, &result) return } diff --git a/supply/category.go b/supply/category.go index d6673c2..0795cfc 100644 --- a/supply/category.go +++ b/supply/category.go @@ -17,7 +17,11 @@ type CategoryItem struct { // All @Title 获取分类 func (c *category) All(ctx context.Context) (result []CategoryItem, err error) { - err = client.GetClient(c).Call(ctx, "All", 0, &result) + xClient, err := client.GetClient(c) + if err != nil { + return + } + err = xClient.Call(ctx, "All", 0, &result) return } @@ -29,7 +33,11 @@ type ArgsCategoryAdd struct { // Add @Title 添加分类 func (c *category) Add(ctx context.Context, args ArgsCategoryAdd) (err error) { reply := 0 - return client.GetClient(c).Call(ctx, "Add", args, &reply) + xClient, err := client.GetClient(c) + if err != nil { + return + } + return xClient.Call(ctx, "Add", args, &reply) } type ArgsCategoryEdit struct { @@ -41,7 +49,11 @@ type ArgsCategoryEdit struct { // Edit @Title 编辑分类 func (c *category) Edit(ctx context.Context, args ArgsCategoryEdit) (err error) { reply := 0 - return client.GetClient(c).Call(ctx, "Edit", args, &reply) + xClient, err := client.GetClient(c) + if err != nil { + return + } + return xClient.Call(ctx, "Edit", args, &reply) } type ArgsCategoryFindByIds struct { @@ -56,6 +68,10 @@ type ThirdCategoryItem struct { // FindByIds @Title 三级分类获取 func (c *category) FindByIds(ctx context.Context, args ArgsCategoryFindByIds) (result []ThirdCategoryItem, err error) { - err = client.GetClient(c).Call(ctx, "FindByIds", args, &result) + xClient, err := client.GetClient(c) + if err != nil { + return + } + err = xClient.Call(ctx, "FindByIds", args, &result) return } diff --git a/supply/channel/order.go b/supply/channel/order.go index 2450dc5..f253939 100644 --- a/supply/channel/order.go +++ b/supply/channel/order.go @@ -27,7 +27,11 @@ type ReplyOrderFreightFee struct { // FreightFee @Title 获取运费 func (o *order) FreightFee(ctx context.Context, channelId string, args ArgsOrderFreightFee) (reply []ReplyOrderFreightFee, err error) { - err = client.GetClient(o).Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "FreightFee", args, &reply) + xClient, err := client.GetClient(o) + if err != nil { + return + } + err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "FreightFee", args, &reply) return } @@ -52,6 +56,10 @@ type ReplyOrderSubmit struct { // Submit @Title 下单 func (o *order) Submit(ctx context.Context, channelId string, args ArgsOrderSubmit) (reply []ReplyOrderSubmit, err error) { - err = client.GetClient(o).Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Submit", args, &reply) + xClient, err := client.GetClient(o) + if err != nil { + return + } + err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Submit", args, &reply) return } diff --git a/supply/channel/sku.go b/supply/channel/sku.go index a4af4e6..ee277f6 100644 --- a/supply/channel/sku.go +++ b/supply/channel/sku.go @@ -51,7 +51,11 @@ type ReplySkuList struct { // Lists @Title 商品列表 func (s *sku) Lists(ctx context.Context, channelId string, args ArgsSkuList) (reply ReplySkuList, err error) { - err = client.GetClient(s).Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Lists", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Lists", args, &reply) return } @@ -103,7 +107,11 @@ type SkuAttribute struct { // Details @Title 获取sku详情 func (s *sku) Details(ctx context.Context, channelId string, args ArgsSkuDetails) (reply []SkuDetailItem, err error) { - err = client.GetClient(s).Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Details", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Details", args, &reply) return } @@ -124,6 +132,10 @@ type ReplySkuStock struct { // Stock @Title 库存查询 func (s *sku) Stock(ctx context.Context, channelId string, args ArgsSkuStock) (reply []ReplySkuStock, err error) { - err = client.GetClient(s).Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Stock", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Stock", args, &reply) return } diff --git a/supply/setting/rate.go b/supply/setting/rate.go index bbde3c8..8ffb1fa 100644 --- a/supply/setting/rate.go +++ b/supply/setting/rate.go @@ -17,7 +17,11 @@ type RateItem struct { // All @Title 全部利率 func (r *rate) All(ctx context.Context) (result []RateItem, err error) { - err = client.GetClient(r).Call(ctx, "All", 0, &result) + xClient, err := client.GetClient(r) + if err != nil { + return + } + err = xClient.Call(ctx, "All", 0, &result) return } @@ -29,5 +33,9 @@ type ArgsRateChannel struct { // Channel @Title 设置渠道利率 func (r *rate) Channel(ctx context.Context, args ArgsRateChannel) error { reply := 0 - return client.GetClient(r).Call(ctx, "Channel", args, &reply) + xClient, err := client.GetClient(r) + if err != nil { + return err + } + return xClient.Call(ctx, "Channel", args, &reply) } diff --git a/supply/sku.go b/supply/sku.go index 24a0725..79ee92f 100644 --- a/supply/sku.go +++ b/supply/sku.go @@ -76,7 +76,11 @@ type SkuAttribute struct { // Add @Title 添加商品 func (s *sku) Add(ctx context.Context, args ArgsSkuAdd) error { reply := 0 - return client.GetClient(s).Call(ctx, "Add", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Add", args, &reply) } type ArgsSkuAdjust struct { @@ -89,7 +93,11 @@ type ArgsSkuAdjust struct { // Adjust @Title 加价 func (s *sku) Adjust(ctx context.Context, args ArgsSkuAdjust) error { reply := 0 - return client.GetClient(s).Call(ctx, "Adjust", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Adjust", args, &reply) } type ArgsSkuLists struct { @@ -143,7 +151,11 @@ type SkuItem struct { // Lists @Title 商品列表 func (s *sku) Lists(ctx context.Context, args ArgsSkuLists) (reply ReplySkuList, err error) { - err = client.GetClient(s).Call(ctx, "Lists", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "Lists", args, &reply) return } @@ -175,7 +187,11 @@ type SkuInfo struct { // Info @Title 商品信息 func (s *sku) Info(ctx context.Context, skuId uint) (reply SkuInfo, err error) { - err = client.GetClient(s).Call(ctx, "Info", skuId, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "Info", skuId, &reply) return } @@ -190,13 +206,21 @@ type ArgsSkuDownShelves struct { // OnShelves @Title 上架 func (s *sku) OnShelves(ctx context.Context, args ArgsSkuOnShelves) error { reply := 0 - return client.GetClient(s).Call(ctx, "OnShelves", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "OnShelves", args, &reply) } // DownShelves @Title 下架 func (s *sku) DownShelves(ctx context.Context, args ArgsSkuDownShelves) error { reply := 0 - return client.GetClient(s).Call(ctx, "DownShelves", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "DownShelves", args, &reply) } type ArgsSkuAdjustType struct { @@ -209,5 +233,9 @@ type ArgsSkuAdjustType struct { // EditAdjust @Title 修改改价类型 func (s *sku) EditAdjust(ctx context.Context, args ArgsSkuAdjustType) error { reply := 0 - return client.GetClient(s).Call(ctx, "EditAdjust", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "EditAdjust", args, &reply) } diff --git a/supply/skuAudit.go b/supply/skuAudit.go index 6058a5f..5624d0b 100644 --- a/supply/skuAudit.go +++ b/supply/skuAudit.go @@ -53,7 +53,11 @@ type ReplySkuAuditLists struct { // Lists @Title 审核列表 func (s *skuAudit) Lists(ctx context.Context, args ArgsSkuAuditLists) (reply ReplySkuAuditLists, err error) { - err = client.GetClient(s).Call(ctx, "Lists", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "Lists", args, &reply) return } @@ -65,7 +69,11 @@ type ArgsSkuAuditAdopt struct { // Adopt @Title 通过 func (s *skuAudit) Adopt(ctx context.Context, args ArgsSkuAuditAdopt) error { reply := 0 - return client.GetClient(s).Call(ctx, "Adopt", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Adopt", args, &reply) } type ArgsSkuAuditReject struct { @@ -77,7 +85,11 @@ type ArgsSkuAuditReject struct { // Reject @Title 驳回 func (s *skuAudit) Reject(ctx context.Context, args ArgsSkuAuditReject) error { reply := 0 - return client.GetClient(s).Call(ctx, "Reject", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Reject", args, &reply) } // Stock @Title 库存查询