| 
									
										
										
										
											2025-07-28 01:46:39 +08:00
										 |  |  |  | package processors | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | import ( | 
					
						
							|  |  |  |  | 	"context" | 
					
						
							|  |  |  |  | 	"tyapi-server/internal/application/api/commands" | 
					
						
							| 
									
										
										
										
											2025-08-04 17:16:38 +08:00
										 |  |  |  | 	"tyapi-server/internal/infrastructure/external/alicloud" | 
					
						
							| 
									
										
										
										
											2025-07-30 00:51:22 +08:00
										 |  |  |  | 	"tyapi-server/internal/infrastructure/external/tianyancha" | 
					
						
							| 
									
										
										
										
											2025-07-28 01:46:39 +08:00
										 |  |  |  | 	"tyapi-server/internal/infrastructure/external/westdex" | 
					
						
							| 
									
										
										
										
											2025-10-16 18:35:18 +08:00
										 |  |  |  | 	"tyapi-server/internal/infrastructure/external/xingwei" | 
					
						
							| 
									
										
										
										
											2025-07-28 01:46:39 +08:00
										 |  |  |  | 	"tyapi-server/internal/infrastructure/external/yushan" | 
					
						
							| 
									
										
										
										
											2025-08-25 15:44:06 +08:00
										 |  |  |  | 	"tyapi-server/internal/infrastructure/external/zhicha" | 
					
						
							| 
									
										
										
										
											2025-07-28 01:46:39 +08:00
										 |  |  |  | 	"tyapi-server/internal/shared/interfaces" | 
					
						
							|  |  |  |  | ) | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // CombServiceInterface 组合包服务接口 | 
					
						
							|  |  |  |  | type CombServiceInterface interface { | 
					
						
							| 
									
										
										
										
											2025-08-02 02:54:21 +08:00
										 |  |  |  | 	ProcessCombRequest(ctx context.Context, params []byte, deps *ProcessorDependencies, packageCode string) (*CombinedResult, error) | 
					
						
							| 
									
										
										
										
											2025-07-28 01:46:39 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-04 22:02:09 +08:00
										 |  |  |  | // CallContext CallApi调用上下文,包含调用相关的数据 | 
					
						
							|  |  |  |  | type CallContext struct { | 
					
						
							|  |  |  |  | 	ContractCode string // 合同编号 | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-28 01:46:39 +08:00
										 |  |  |  | // ProcessorDependencies 处理器依赖容器 | 
					
						
							|  |  |  |  | type ProcessorDependencies struct { | 
					
						
							| 
									
										
										
										
											2025-07-30 00:51:22 +08:00
										 |  |  |  | 	WestDexService    *westdex.WestDexService | 
					
						
							|  |  |  |  | 	YushanService     *yushan.YushanService | 
					
						
							|  |  |  |  | 	TianYanChaService *tianyancha.TianYanChaService | 
					
						
							| 
									
										
										
										
											2025-08-04 17:16:38 +08:00
										 |  |  |  | 	AlicloudService   *alicloud.AlicloudService | 
					
						
							| 
									
										
										
										
											2025-08-25 15:44:06 +08:00
										 |  |  |  | 	ZhichaService     *zhicha.ZhichaService | 
					
						
							| 
									
										
										
										
											2025-10-16 18:35:18 +08:00
										 |  |  |  | 	XingweiService    *xingwei.XingweiService | 
					
						
							| 
									
										
										
										
											2025-07-30 00:51:22 +08:00
										 |  |  |  | 	Validator         interfaces.RequestValidator | 
					
						
							|  |  |  |  | 	CombService       CombServiceInterface // Changed to interface to break import cycle | 
					
						
							|  |  |  |  | 	Options           *commands.ApiCallOptions // 添加Options支持 | 
					
						
							| 
									
										
										
										
											2025-08-04 22:02:09 +08:00
										 |  |  |  | 	CallContext       *CallContext // 添加CallApi调用上下文 | 
					
						
							| 
									
										
										
										
											2025-07-28 01:46:39 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // NewProcessorDependencies 创建处理器依赖容器 | 
					
						
							|  |  |  |  | func NewProcessorDependencies( | 
					
						
							|  |  |  |  | 	westDexService *westdex.WestDexService, | 
					
						
							|  |  |  |  | 	yushanService *yushan.YushanService, | 
					
						
							| 
									
										
										
										
											2025-07-30 00:51:22 +08:00
										 |  |  |  | 	tianYanChaService *tianyancha.TianYanChaService, | 
					
						
							| 
									
										
										
										
											2025-08-04 17:16:38 +08:00
										 |  |  |  | 	alicloudService *alicloud.AlicloudService, | 
					
						
							| 
									
										
										
										
											2025-08-25 15:44:06 +08:00
										 |  |  |  | 	zhichaService *zhicha.ZhichaService, | 
					
						
							| 
									
										
										
										
											2025-10-16 18:35:18 +08:00
										 |  |  |  | 	xingweiService *xingwei.XingweiService, | 
					
						
							| 
									
										
										
										
											2025-07-28 01:46:39 +08:00
										 |  |  |  | 	validator interfaces.RequestValidator, | 
					
						
							|  |  |  |  | 	combService CombServiceInterface, // Changed to interface | 
					
						
							|  |  |  |  | ) *ProcessorDependencies { | 
					
						
							|  |  |  |  | 	return &ProcessorDependencies{ | 
					
						
							| 
									
										
										
										
											2025-07-30 00:51:22 +08:00
										 |  |  |  | 		WestDexService:    westDexService, | 
					
						
							|  |  |  |  | 		YushanService:     yushanService, | 
					
						
							|  |  |  |  | 		TianYanChaService: tianYanChaService, | 
					
						
							| 
									
										
										
										
											2025-08-04 17:16:38 +08:00
										 |  |  |  | 		AlicloudService:   alicloudService, | 
					
						
							| 
									
										
										
										
											2025-08-25 15:44:06 +08:00
										 |  |  |  | 		ZhichaService:     zhichaService, | 
					
						
							| 
									
										
										
										
											2025-10-16 18:35:18 +08:00
										 |  |  |  | 		XingweiService:    xingweiService, | 
					
						
							| 
									
										
										
										
											2025-07-30 00:51:22 +08:00
										 |  |  |  | 		Validator:         validator, | 
					
						
							|  |  |  |  | 		CombService:       combService, | 
					
						
							|  |  |  |  | 		Options:           nil, // 初始化为nil,在调用时设置 | 
					
						
							| 
									
										
										
										
											2025-08-04 22:02:09 +08:00
										 |  |  |  | 		CallContext:       nil, // 初始化为nil,在调用时设置 | 
					
						
							| 
									
										
										
										
											2025-07-28 01:46:39 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // WithOptions 设置Options的便捷方法 | 
					
						
							|  |  |  |  | func (deps *ProcessorDependencies) WithOptions(options *commands.ApiCallOptions) *ProcessorDependencies { | 
					
						
							|  |  |  |  | 	deps.Options = options | 
					
						
							|  |  |  |  | 	return deps | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-04 22:02:09 +08:00
										 |  |  |  | // WithCallContext 设置CallContext的便捷方法 | 
					
						
							|  |  |  |  | func (deps *ProcessorDependencies) WithCallContext(callContext *CallContext) *ProcessorDependencies { | 
					
						
							|  |  |  |  | 	deps.CallContext = callContext | 
					
						
							|  |  |  |  | 	return deps | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-28 01:46:39 +08:00
										 |  |  |  | // ProcessorFunc 处理器函数类型定义 | 
					
						
							| 
									
										
										
										
											2025-08-02 02:54:21 +08:00
										 |  |  |  | type ProcessorFunc func(ctx context.Context, params []byte, deps *ProcessorDependencies) ([]byte, error)  | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // CombinedResult 组合结果 | 
					
						
							|  |  |  |  | type CombinedResult struct { | 
					
						
							|  |  |  |  | 	Responses []*SubProductResult `json:"responses"` // 子接口响应列表 | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // SubProductResult 子产品处理结果 | 
					
						
							|  |  |  |  | type SubProductResult struct { | 
					
						
							|  |  |  |  | 	ApiCode   string      `json:"api_code"`        // 子接口标识 | 
					
						
							|  |  |  |  | 	Data      interface{} `json:"data"`            // 子接口返回数据 | 
					
						
							|  |  |  |  | 	Success   bool        `json:"success"`         // 是否成功 | 
					
						
							|  |  |  |  | 	Error     string      `json:"error,omitempty"` // 错误信息(仅在失败时) | 
					
						
							|  |  |  |  | 	SortOrder int         `json:"-"`               // 排序字段,不输出到JSON | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 |