2025-07-28 01:46:39 +08:00
|
|
|
|
package processors
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"context"
|
|
|
|
|
|
"tyapi-server/internal/application/api/commands"
|
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"
|
|
|
|
|
|
"tyapi-server/internal/infrastructure/external/yushan"
|
|
|
|
|
|
"tyapi-server/internal/shared/interfaces"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// CombServiceInterface 组合包服务接口
|
|
|
|
|
|
type CombServiceInterface interface {
|
|
|
|
|
|
ProcessCombRequest(ctx context.Context, params []byte, deps *ProcessorDependencies, packageCode string) ([]byte, error)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ProcessorDependencies 处理器依赖容器
|
|
|
|
|
|
type ProcessorDependencies struct {
|
2025-07-30 00:51:22 +08:00
|
|
|
|
WestDexService *westdex.WestDexService
|
|
|
|
|
|
YushanService *yushan.YushanService
|
|
|
|
|
|
TianYanChaService *tianyancha.TianYanChaService
|
|
|
|
|
|
Validator interfaces.RequestValidator
|
|
|
|
|
|
CombService CombServiceInterface // Changed to interface to break import cycle
|
|
|
|
|
|
Options *commands.ApiCallOptions // 添加Options支持
|
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-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,
|
|
|
|
|
|
Validator: validator,
|
|
|
|
|
|
CombService: combService,
|
|
|
|
|
|
Options: 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
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ProcessorFunc 处理器函数类型定义
|
|
|
|
|
|
type ProcessorFunc func(ctx context.Context, params []byte, deps *ProcessorDependencies) ([]byte, error)
|