From 8eec9685db632fae8abcb502de0766f6acfc8735 Mon Sep 17 00:00:00 2001 From: Mrx <18278715334@163.com> Date: Mon, 23 Mar 2026 12:36:23 +0800 Subject: [PATCH] f --- .../external/jiguang/jiguang_service.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/internal/infrastructure/external/jiguang/jiguang_service.go b/internal/infrastructure/external/jiguang/jiguang_service.go index 8788243..9012f46 100644 --- a/internal/infrastructure/external/jiguang/jiguang_service.go +++ b/internal/infrastructure/external/jiguang/jiguang_service.go @@ -222,13 +222,12 @@ func (j *JiguangService) CallAPI(ctx context.Context, apiCode string, apiPath st } // 检查业务状态码 - if jiguangResp.Code != 0 && jiguangResp.Code != 200 { + if jiguangResp.Code != 0 && jiguangResp.Code != 200 && jiguangResp.Code != 400 { // 创建极光错误 jiguangErr := NewJiguangErrorFromCode(jiguangResp.Code) if jiguangErr.Message == fmt.Sprintf("未知错误码: %d", jiguangResp.Code) && jiguangResp.Msg != "" { jiguangErr.Message = jiguangResp.Msg } - // 根据错误类型返回不同的错误 if jiguangErr.IsNoRecord() { // 从context中获取apiCode,判断是否需要抛出异常 @@ -236,33 +235,27 @@ func (j *JiguangService) CallAPI(ctx context.Context, apiCode string, apiPath st if ctxProcessorCode, ok := ctx.Value("api_code").(string); ok { processorCode = ctxProcessorCode } - // 定义不需要抛出异常的处理器列表(默认情况下查无记录时抛出异常) processorsNotToThrowError := map[string]bool{ // 在这个列表中的处理器,查无记录时返回空数组,不抛出异常 // 示例:如果需要添加某个处理器,取消下面的注释 // "QCXG9P1C": true, } - // 如果是不需要抛出异常的处理器,返回空数组;否则(默认)抛出异常 if processorsNotToThrowError[processorCode] { // 查无记录时,返回空数组,API调用记录为成功 return []byte("[]"), nil } - - // 默认情况下,查无记录时抛出异常 // 记录错误日志 if j.logger != nil { j.logger.LogErrorWithResponseID(requestID, transactionID, apiCode, jiguangErr, params, jiguangResp.OrderID) } return nil, errors.Join(ErrNotFound, jiguangErr) } - // 记录错误日志(查无记录的情况不记录错误日志) if j.logger != nil { j.logger.LogErrorWithResponseID(requestID, transactionID, apiCode, jiguangErr, params, jiguangResp.OrderID) } - if jiguangErr.IsQueryFailed() { return nil, errors.Join(ErrDatasource, jiguangErr) } else if jiguangErr.IsSystemError() { @@ -272,11 +265,6 @@ func (j *JiguangService) CallAPI(ctx context.Context, apiCode string, apiPath st } } - // 成功响应,返回data字段 - if jiguangResp.Data == nil { - return []byte("{}"), nil - } - // 将data转换为JSON字节 dataBytes, err := json.Marshal(jiguangResp.Data) if err != nil {