From 6905936cf319e4e67db2409a9dba4a69fd079cd0 Mon Sep 17 00:00:00 2001 From: Mrx <18278715334@163.com> Date: Tue, 20 Jan 2026 11:29:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=89=AF=E5=BF=83=E8=80=81=E6=9D=BF=E7=A9=BA?= =?UTF-8?q?=E4=B8=8D=E6=89=A3=E8=B4=B9=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../external/jiguang/jiguang_service.go | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/internal/infrastructure/external/jiguang/jiguang_service.go b/internal/infrastructure/external/jiguang/jiguang_service.go index 68a7aac..465da4d 100644 --- a/internal/infrastructure/external/jiguang/jiguang_service.go +++ b/internal/infrastructure/external/jiguang/jiguang_service.go @@ -237,24 +237,25 @@ func (j *JiguangService) CallAPI(ctx context.Context, apiCode string, apiPath st processorCode = ctxProcessorCode } - // 定义需要在查无记录时抛出异常的处理器列表 - processorsToThrowError := map[string]bool{ - "QCXG9P1C": true, // QCXG9P1C 处理器在查无记录时需要抛出异常 - "QCXG4D2E": true, // QCXG4D2E 处理器在查无记录时需要抛出异常 - "QCXG5F3A": true, // QCXG5F3A 处理器在查无记录时需要抛出异常 + // 定义不需要抛出异常的处理器列表(默认情况下查无记录时抛出异常) + processorsNotToThrowError := map[string]bool{ + // 在这个列表中的处理器,查无记录时返回空数组,不抛出异常 + // 示例:如果需要添加某个处理器,取消下面的注释 + // "QCXG9P1C": true, } - // 如果是特定处理器,抛出异常;否则返回空数组 - if processorsToThrowError[processorCode] { - // 记录错误日志 - if j.logger != nil { - j.logger.LogErrorWithResponseID(requestID, transactionID, apiCode, jiguangErr, params, jiguangResp.OrderID) - } - return nil, errors.Join(ErrNotFound, jiguangErr) + // 如果是不需要抛出异常的处理器,返回空数组;否则(默认)抛出异常 + if processorsNotToThrowError[processorCode] { + // 查无记录时,返回空数组,API调用记录为成功 + return []byte("[]"), nil } - // 查无记录时,返回空数组,API调用记录为成功 - return []byte("[]"), nil + // 默认情况下,查无记录时抛出异常 + // 记录错误日志 + if j.logger != nil { + j.logger.LogErrorWithResponseID(requestID, transactionID, apiCode, jiguangErr, params, jiguangResp.OrderID) + } + return nil, errors.Join(ErrNotFound, jiguangErr) } // 记录错误日志(查无记录的情况不记录错误日志)