f
This commit is contained in:
@@ -19,7 +19,7 @@ import (
|
||||
var (
|
||||
ErrDatasource = errors.New("数据源异常")
|
||||
ErrSystem = errors.New("系统异常")
|
||||
ErrNotFound = errors.New("查询为空")
|
||||
ErrNotFound = errors.New("查询为空")
|
||||
)
|
||||
|
||||
type WestResp struct {
|
||||
@@ -72,7 +72,6 @@ func (w *WestDexService) generateRequestID() string {
|
||||
return fmt.Sprintf("westdex_%x", hash[:8])
|
||||
}
|
||||
|
||||
|
||||
// buildRequestURL 构建请求URL
|
||||
func (w *WestDexService) buildRequestURL(code string) string {
|
||||
timestamp := strconv.FormatInt(time.Now().UnixNano()/int64(time.Millisecond), 10)
|
||||
@@ -132,14 +131,13 @@ func (w *WestDexService) CallAPI(ctx context.Context, code string, reqData map[s
|
||||
isTimeout = true
|
||||
} else if netErr, ok := clientDoErr.(interface{ Timeout() bool }); ok && netErr.Timeout() {
|
||||
isTimeout = true
|
||||
} else if errStr := clientDoErr.Error();
|
||||
errStr == "context deadline exceeded" ||
|
||||
errStr == "timeout" ||
|
||||
errStr == "Client.Timeout exceeded" ||
|
||||
errStr == "net/http: request canceled" {
|
||||
} else if errStr := clientDoErr.Error(); errStr == "context deadline exceeded" ||
|
||||
errStr == "timeout" ||
|
||||
errStr == "Client.Timeout exceeded" ||
|
||||
errStr == "net/http: request canceled" {
|
||||
isTimeout = true
|
||||
}
|
||||
|
||||
|
||||
if isTimeout {
|
||||
err = errors.Join(ErrDatasource, fmt.Errorf("API请求超时: %v", clientDoErr))
|
||||
} else {
|
||||
@@ -185,7 +183,6 @@ func (w *WestDexService) CallAPI(ctx context.Context, code string, reqData map[s
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 记录响应日志(不记录具体响应数据)
|
||||
if w.logger != nil {
|
||||
w.logger.LogResponseWithID(requestID, transactionID, code, httpResp.StatusCode, duration, westDexResp.ID)
|
||||
@@ -305,14 +302,13 @@ func (w *WestDexService) G05HZ01CallAPI(ctx context.Context, code string, reqDat
|
||||
isTimeout = true
|
||||
} else if netErr, ok := clientDoErr.(interface{ Timeout() bool }); ok && netErr.Timeout() {
|
||||
isTimeout = true
|
||||
} else if errStr := clientDoErr.Error();
|
||||
errStr == "context deadline exceeded" ||
|
||||
errStr == "timeout" ||
|
||||
errStr == "Client.Timeout exceeded" ||
|
||||
errStr == "net/http: request canceled" {
|
||||
} else if errStr := clientDoErr.Error(); errStr == "context deadline exceeded" ||
|
||||
errStr == "timeout" ||
|
||||
errStr == "Client.Timeout exceeded" ||
|
||||
errStr == "net/http: request canceled" {
|
||||
isTimeout = true
|
||||
}
|
||||
|
||||
|
||||
if isTimeout {
|
||||
err = errors.Join(ErrDatasource, fmt.Errorf("API请求超时: %v", clientDoErr))
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user