diff --git a/internal/domains/api/services/processors/jrzq/jrzqv3hm_processor.go b/internal/domains/api/services/processors/jrzq/jrzqv3hm_processor.go index 05f5d6a..df84141 100644 --- a/internal/domains/api/services/processors/jrzq/jrzqv3hm_processor.go +++ b/internal/domains/api/services/processors/jrzq/jrzqv3hm_processor.go @@ -29,7 +29,7 @@ func ProcessJRZQV3HMRequest(ctx context.Context, params []byte, deps *processors nuoerDoCheckAPIKey := "blackListV121_3_1" ApiPath := "/v1/doCheck" - resp, err := deps.NuoerService.CallAPI(ctx, nuoerDoCheckAPIKey, ApiPath, body) + resp, err := deps.NuoerService.CallAPI(ctx, nuoerDoCheckAPIKey, ApiPath, body, nuoer.WithEncryptionType(2)) if err != nil { if errors.Is(err, nuoer.ErrDatasource) { return nil, errors.Join(processors.ErrDatasource, err) diff --git a/internal/infrastructure/external/nuoer/nuoer_service.go b/internal/infrastructure/external/nuoer/nuoer_service.go index b9c0583..c18ba4b 100644 --- a/internal/infrastructure/external/nuoer/nuoer_service.go +++ b/internal/infrastructure/external/nuoer/nuoer_service.go @@ -91,7 +91,25 @@ func (s *NuoerService) logError(transactionID, apiKey, seqNo string, err error, s.logger.LogError(seqNo, transactionID, apiKey, err, payload) } -func (s *NuoerService) CallAPI(ctx context.Context, apiKey, apiPath string, body map[string]string) (*nuoerResponse, error) { +// CallAPIOption 诺尔智汇 CallAPI 可选参数 +type CallAPIOption func(*callAPIConfig) + +type callAPIConfig struct { + encryptionType int +} + +// WithEncryptionType 指定入参加密类型(如 MD5 入参为 2) +func WithEncryptionType(encryptionType int) CallAPIOption { + return func(c *callAPIConfig) { + c.encryptionType = encryptionType + } +} + +func (s *NuoerService) CallAPI(ctx context.Context, apiKey, apiPath string, body map[string]string, opts ...CallAPIOption) (*nuoerResponse, error) { + cfg := callAPIConfig{} + for _, opt := range opts { + opt(&cfg) + } requestURL := strings.TrimSuffix(s.config.URL, "/") if apiPath != "" { if !strings.HasPrefix(apiPath, "/") { @@ -116,6 +134,9 @@ func (s *NuoerService) CallAPI(ctx context.Context, apiKey, apiPath string, body "apiKey": apiKey, "body": body, } + if cfg.encryptionType != 0 { + requestPayload["encryptionType"] = cfg.encryptionType + } if s.logger != nil { s.logger.LogRequest("", transactionID, apiKey, requestURL)