新增部分接口合同授权码

This commit is contained in:
2025-08-04 22:02:09 +08:00
parent f482f0a6e8
commit 3f4c3086f3
6 changed files with 57 additions and 21 deletions

View File

@@ -147,10 +147,10 @@ func registerAllProcessors(combService *comb.CombService) {
var RequestProcessors map[string]processors.ProcessorFunc
// PreprocessRequestApi 调用指定的请求处理函数
func (a *ApiRequestService) PreprocessRequestApi(ctx context.Context, apiCode string, params []byte, options *commands.ApiCallOptions) ([]byte, error) {
func (a *ApiRequestService) PreprocessRequestApi(ctx context.Context, apiCode string, params []byte, options *commands.ApiCallOptions, callContext *processors.CallContext) ([]byte, error) {
if processor, exists := RequestProcessors[apiCode]; exists {
// 设置Options到依赖容器
deps := a.processorDeps.WithOptions(options)
// 设置Options和CallContext到依赖容器
deps := a.processorDeps.WithOptions(options).WithCallContext(callContext)
return processor(ctx, params, deps)
}
return nil, fmt.Errorf("%s: 未找到处理器: %s", ErrSystem, apiCode)

View File

@@ -15,6 +15,11 @@ type CombServiceInterface interface {
ProcessCombRequest(ctx context.Context, params []byte, deps *ProcessorDependencies, packageCode string) (*CombinedResult, error)
}
// CallContext CallApi调用上下文包含调用相关的数据
type CallContext struct {
ContractCode string // 合同编号
}
// ProcessorDependencies 处理器依赖容器
type ProcessorDependencies struct {
WestDexService *westdex.WestDexService
@@ -24,6 +29,7 @@ type ProcessorDependencies struct {
Validator interfaces.RequestValidator
CombService CombServiceInterface // Changed to interface to break import cycle
Options *commands.ApiCallOptions // 添加Options支持
CallContext *CallContext // 添加CallApi调用上下文
}
// NewProcessorDependencies 创建处理器依赖容器
@@ -43,6 +49,7 @@ func NewProcessorDependencies(
Validator: validator,
CombService: combService,
Options: nil, // 初始化为nil在调用时设置
CallContext: nil, // 初始化为nil在调用时设置
}
}
@@ -52,6 +59,12 @@ func (deps *ProcessorDependencies) WithOptions(options *commands.ApiCallOptions)
return deps
}
// WithCallContext 设置CallContext的便捷方法
func (deps *ProcessorDependencies) WithCallContext(callContext *CallContext) *ProcessorDependencies {
deps.CallContext = callContext
return deps
}
// ProcessorFunc 处理器函数类型定义
type ProcessorFunc func(ctx context.Context, params []byte, deps *ProcessorDependencies) ([]byte, error)

View File

@@ -33,13 +33,16 @@ func ProcessFLXG0V4BRequest(ctx context.Context, params []byte, deps *processors
if err != nil {
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err)
}
encryptedAuthAuthorizeFileCode, err := deps.WestDexService.Encrypt(deps.CallContext.ContractCode)
if err != nil {
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"data": map[string]interface{}{
"name": encryptedName,
"idcard": encryptedIDCard,
"auth_authorizeFileCode": encryptedAuthAuthorizeFileCode,
"inquired_auth": paramsDto.AuthDate,
// "auth_authorizeFileCode": paramsDto.AuthAuthorizeFileCode,
},
}
respBytes, err := deps.WestDexService.CallAPI("G22SC01", reqData)

View File

@@ -31,11 +31,15 @@ func ProcessQYGL8271Request(ctx context.Context, params []byte, deps *processors
if err != nil {
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err)
}
encryptedAuthAuthorizeFileCode, err := deps.WestDexService.Encrypt(deps.CallContext.ContractCode)
if err != nil {
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"data": map[string]interface{}{
"org_name": encryptedEntName,
"uscc": encryptedEntCode,
"auth_authorizeFileCode": encryptedAuthAuthorizeFileCode,
"inquired_auth": paramsDto.AuthDate, // AuthDate 有 encrypt:"false" 标签,不加密
},
}