fix
This commit is contained in:
@@ -34,7 +34,7 @@ type ZhichaResp struct {
|
||||
type ZhichaConfig struct {
|
||||
URL string
|
||||
AppID string
|
||||
AppSecret string
|
||||
AppSecret string
|
||||
EncryptKey string
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ func (z *ZhichaService) CallAPI(ctx context.Context, proID string, params map[st
|
||||
|
||||
jsonData, marshalErr := json.Marshal(params)
|
||||
if marshalErr != nil {
|
||||
err = fmt.Errorf("%w: %s", ErrSystem, marshalErr.Error())
|
||||
err = errors.Join(ErrSystem, marshalErr)
|
||||
if z.logger != nil {
|
||||
z.logger.LogError(requestID, transactionID, proID, err, params)
|
||||
}
|
||||
@@ -104,7 +104,7 @@ func (z *ZhichaService) CallAPI(ctx context.Context, proID string, params map[st
|
||||
// 创建HTTP POST请求
|
||||
req, err := http.NewRequestWithContext(ctx, "POST", z.config.URL, bytes.NewBuffer(jsonData))
|
||||
if err != nil {
|
||||
err = fmt.Errorf("%w: %s", ErrSystem, err.Error())
|
||||
err = errors.Join(ErrSystem, err)
|
||||
if z.logger != nil {
|
||||
z.logger.LogError(requestID, transactionID, proID, err, params)
|
||||
}
|
||||
@@ -126,7 +126,7 @@ func (z *ZhichaService) CallAPI(ctx context.Context, proID string, params map[st
|
||||
// 发送请求
|
||||
response, err := client.Do(req)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("%w: %s", ErrSystem, err.Error())
|
||||
err = errors.Join(ErrSystem, err)
|
||||
if z.logger != nil {
|
||||
z.logger.LogError(requestID, transactionID, proID, err, params)
|
||||
}
|
||||
@@ -137,7 +137,7 @@ func (z *ZhichaService) CallAPI(ctx context.Context, proID string, params map[st
|
||||
// 读取响应
|
||||
respBody, err := io.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("%w: %s", ErrSystem, err.Error())
|
||||
err = errors.Join(ErrSystem, err)
|
||||
if z.logger != nil {
|
||||
z.logger.LogError(requestID, transactionID, proID, err, params)
|
||||
}
|
||||
@@ -152,7 +152,7 @@ func (z *ZhichaService) CallAPI(ctx context.Context, proID string, params map[st
|
||||
|
||||
// 检查HTTP状态码
|
||||
if response.StatusCode != http.StatusOK {
|
||||
err = fmt.Errorf("%w: HTTP状态码 %d", ErrDatasource, response.StatusCode)
|
||||
err = errors.Join(ErrDatasource, fmt.Errorf("HTTP状态码 %d", response.StatusCode))
|
||||
if z.logger != nil {
|
||||
z.logger.LogError(requestID, transactionID, proID, err, params)
|
||||
}
|
||||
@@ -162,7 +162,7 @@ func (z *ZhichaService) CallAPI(ctx context.Context, proID string, params map[st
|
||||
// 解析响应
|
||||
var zhichaResp ZhichaResp
|
||||
if err := json.Unmarshal(respBody, &zhichaResp); err != nil {
|
||||
err = fmt.Errorf("%w: 响应解析失败: %s", ErrSystem, err.Error())
|
||||
err = errors.Join(ErrSystem, fmt.Errorf("响应解析失败: %s", err.Error()))
|
||||
if z.logger != nil {
|
||||
z.logger.LogError(requestID, transactionID, proID, err, params)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user