This commit is contained in:
@@ -21,13 +21,13 @@ var (
|
||||
|
||||
// APIEndpoints 天眼查 API 端点映射
|
||||
var APIEndpoints = map[string]string{
|
||||
"VerifyThreeElements": "/open/ic/verify/2.0", // 企业三要素验证
|
||||
"InvestHistory": "/open/hi/invest/2.0", // 对外投资历史
|
||||
"FinancingHistory": "/open/cd/findHistoryRongzi/2.0", // 融资历史
|
||||
"PunishmentInfo": "/open/mr/punishmentInfo/3.0", // 行政处罚
|
||||
"AbnormalInfo": "/open/mr/abnormal/2.0", // 经营异常
|
||||
"OwnTax": "/open/mr/ownTax", // 欠税公告
|
||||
"TaxContravention": "/open/mr/taxContravention", // 税收违法
|
||||
"VerifyThreeElements": "/open/ic/verify/2.0", // 企业三要素验证
|
||||
"InvestHistory": "/open/hi/invest/2.0", // 对外投资历史
|
||||
"FinancingHistory": "/open/cd/findHistoryRongzi/2.0", // 融资历史
|
||||
"PunishmentInfo": "/open/mr/punishmentInfo/3.0", // 行政处罚
|
||||
"AbnormalInfo": "/open/mr/abnormal/2.0", // 经营异常
|
||||
"OwnTax": "/open/mr/ownTax", // 欠税公告
|
||||
"TaxContravention": "/open/mr/taxContravention", // 税收违法
|
||||
}
|
||||
|
||||
// TianYanChaConfig 天眼查配置
|
||||
@@ -56,6 +56,7 @@ type TianYanChaResponse struct {
|
||||
Reason string `json:"reason"`
|
||||
Result interface{} `json:"result"`
|
||||
}
|
||||
|
||||
// NewTianYanChaService 创建天眼查服务实例
|
||||
func NewTianYanChaService(baseURL, token string, timeout time.Duration) *TianYanChaService {
|
||||
if timeout == 0 {
|
||||
@@ -118,14 +119,13 @@ func (t *TianYanChaService) CallAPI(ctx context.Context, apiCode string, params
|
||||
isTimeout = true
|
||||
} else if netErr, ok := err.(interface{ Timeout() bool }); ok && netErr.Timeout() {
|
||||
isTimeout = true
|
||||
} else if errStr := err.Error();
|
||||
errStr == "context deadline exceeded" ||
|
||||
errStr == "timeout" ||
|
||||
errStr == "Client.Timeout exceeded" ||
|
||||
errStr == "net/http: request canceled" {
|
||||
} else if errStr := err.Error(); errStr == "context deadline exceeded" ||
|
||||
errStr == "timeout" ||
|
||||
errStr == "Client.Timeout exceeded" ||
|
||||
errStr == "net/http: request canceled" {
|
||||
isTimeout = true
|
||||
}
|
||||
|
||||
|
||||
if isTimeout {
|
||||
return nil, errors.Join(ErrDatasource, fmt.Errorf("API请求超时: %v", err))
|
||||
}
|
||||
@@ -156,7 +156,7 @@ func (t *TianYanChaService) CallAPI(ctx context.Context, apiCode string, params
|
||||
if tianYanChaResp.ErrorCode == 300000 {
|
||||
return nil, errors.Join(ErrNotFound, fmt.Errorf("天眼查查询为空: %s", tianYanChaResp.Reason))
|
||||
}
|
||||
|
||||
|
||||
return &APIResponse{
|
||||
Success: false,
|
||||
Code: tianYanChaResp.ErrorCode,
|
||||
|
||||
Reference in New Issue
Block a user