f
This commit is contained in:
@@ -13,10 +13,6 @@ func convertTianYanChaError(err error) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查天眼查服务的错误类型,转换为处理器层的标准错误
|
|
||||||
if errors.Is(err, tianyancha.ErrNotFound) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if errors.Is(err, tianyancha.ErrDatasource) {
|
if errors.Is(err, tianyancha.ErrDatasource) {
|
||||||
return errors.Join(processors.ErrDatasource, err)
|
return errors.Join(processors.ErrDatasource, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,9 +155,14 @@ func (t *TianYanChaService) CallAPI(ctx context.Context, apiCode string, params
|
|||||||
|
|
||||||
// 检查天眼查业务状态码
|
// 检查天眼查业务状态码
|
||||||
if tianYanChaResp.ErrorCode != 0 {
|
if tianYanChaResp.ErrorCode != 0 {
|
||||||
// 特殊处理:ErrorCode 300000 表示查询为空,返回ErrNotFound
|
// 特殊处理:ErrorCode 300000 表示查询为空,返回成功但数据为空
|
||||||
if tianYanChaResp.ErrorCode == 300000 {
|
if tianYanChaResp.ErrorCode == 300000 {
|
||||||
return nil, errors.Join(ErrNotFound, fmt.Errorf("天眼查查询为空: %s", tianYanChaResp.Reason))
|
return &APIResponse{
|
||||||
|
Success: true,
|
||||||
|
Code: 0,
|
||||||
|
Message: "查询为空",
|
||||||
|
Data: nil,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return &APIResponse{
|
return &APIResponse{
|
||||||
@@ -166,7 +171,6 @@ func (t *TianYanChaService) CallAPI(ctx context.Context, apiCode string, params
|
|||||||
Message: tianYanChaResp.Reason,
|
Message: tianYanChaResp.Reason,
|
||||||
Data: tianYanChaResp.Result,
|
Data: tianYanChaResp.Result,
|
||||||
}, nil
|
}, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 成功情况
|
// 成功情况
|
||||||
|
|||||||
Reference in New Issue
Block a user