fix: 1. msg -> message 字段错误处理 2.分类查询调整为仅3级分类

This commit is contained in:
fuzhongyun 2025-12-24 17:19:30 +08:00
parent 8a626b3b58
commit 7682ecd75b
7 changed files with 12 additions and 9 deletions

View File

@ -38,7 +38,7 @@ func (c *Client) Call(ctx context.Context, req *GoodsAddRequest) (*GoodsAddRespo
type resType struct {
Code int `json:"code"`
Msg string `json:"msg"`
Msg string `json:"message"`
Data struct {
Id int `json:"id"` // 商品 ID
} `json:"data"`
@ -50,7 +50,7 @@ func (c *Client) Call(ctx context.Context, req *GoodsAddRequest) (*GoodsAddRespo
}
if resData.Code != 200 {
return nil, fmt.Errorf("业务错误,code: %d, msg: %s", resData.Code, resData.Msg)
return nil, fmt.Errorf("业务错误,%s", resData.Msg)
}
toolResp := &GoodsAddResponse{

View File

@ -12,7 +12,7 @@ type SearchCondition struct {
type GoodsBrandSearchResponse struct {
Code int `json:"code"`
Msg string `json:"msg"`
Msg string `json:"message"`
Data struct {
List []BrandInfo `json:"list"`
} `json:"data"`

View File

@ -8,7 +8,7 @@ type GoodsCategoryAddRequest struct {
type GoodsCategoryAddResponse struct {
Code int `json:"code"`
Msg string `json:"msg"`
Msg string `json:"message"`
Data struct {
IsSuccess bool `json:"is_success"` // 是否成功
} `json:"data"`

View File

@ -28,7 +28,8 @@ func (c *Client) Call(ctx context.Context, name string) (int, error) {
Page: 1,
Limit: 1,
Search: SearchCondition{
Name: name,
Name: name,
Level: 3, // 仅需三级分类
},
}

View File

@ -7,12 +7,13 @@ type GoodsCategorySearchRequest struct {
}
type SearchCondition struct {
Name string `json:"name"`
Name string `json:"full_name"`
Level int `json:"level"`
}
type GoodsCategorySearchResponse struct {
Code int `json:"code"`
Msg string `json:"msg"`
Msg string `json:"message"`
Data struct {
List []CategoryInfo `json:"list"`
} `json:"data"`

View File

@ -14,7 +14,7 @@ type MediaItem struct {
type GoodsMediaAddResponse struct {
Code int `json:"code"`
Msg string `json:"msg"`
Msg string `json:"message"`
Data struct {
IsSuccess bool `json:"is_success"`
} `json:"data"`

View File

@ -272,7 +272,8 @@ func (o *goodsAdd) buildWorkflow(ctx context.Context) (compose.Runnable[*GoodsAd
// 调用 goods_add 工具
respData, err := o.toolManager.Hyt.GoodsAdd.Call(ctx, state.AddGoodsReq)
if err != nil || respData == nil {
return nil, fmt.Errorf("新增商品失败")
log.Printf("warning: 新增商品失败: %v", err)
return nil, fmt.Errorf("新增商品失败: %s", err.Error())
}
state.GoodsAddResp = respData