fix
This commit is contained in:
@@ -534,6 +534,11 @@ func NewContainer() *Container {
|
||||
article_repo.NewGormTagRepository,
|
||||
fx.As(new(domain_article_repo.TagRepository)),
|
||||
),
|
||||
// 定时任务仓储 - 同时注册具体类型和接口类型
|
||||
fx.Annotate(
|
||||
article_repo.NewGormScheduledTaskRepository,
|
||||
fx.As(new(domain_article_repo.ScheduledTaskRepository)),
|
||||
),
|
||||
),
|
||||
|
||||
// API域仓储层
|
||||
@@ -621,9 +626,9 @@ func NewContainer() *Container {
|
||||
// 任务系统
|
||||
fx.Provide(
|
||||
// Asynq 客户端
|
||||
func(cfg *config.Config, logger *zap.Logger) *task.AsynqClient {
|
||||
func(cfg *config.Config, scheduledTaskRepo domain_article_repo.ScheduledTaskRepository, logger *zap.Logger) *task.AsynqClient {
|
||||
redisAddr := fmt.Sprintf("%s:%s", cfg.Redis.Host, cfg.Redis.Port)
|
||||
return task.NewAsynqClient(redisAddr, logger)
|
||||
return task.NewAsynqClient(redisAddr, scheduledTaskRepo, logger)
|
||||
},
|
||||
),
|
||||
|
||||
@@ -678,9 +683,27 @@ func NewContainer() *Container {
|
||||
product.NewSubscriptionApplicationService,
|
||||
fx.As(new(product.SubscriptionApplicationService)),
|
||||
),
|
||||
// 任务管理服务
|
||||
article.NewTaskManagementService,
|
||||
// 文章应用服务 - 绑定到接口
|
||||
fx.Annotate(
|
||||
article.NewArticleApplicationService,
|
||||
func(
|
||||
articleRepo domain_article_repo.ArticleRepository,
|
||||
categoryRepo domain_article_repo.CategoryRepository,
|
||||
tagRepo domain_article_repo.TagRepository,
|
||||
articleService *article_service.ArticleService,
|
||||
asynqClient *task.AsynqClient,
|
||||
logger *zap.Logger,
|
||||
) article.ArticleApplicationService {
|
||||
return article.NewArticleApplicationService(
|
||||
articleRepo,
|
||||
categoryRepo,
|
||||
tagRepo,
|
||||
articleService,
|
||||
asynqClient,
|
||||
logger,
|
||||
)
|
||||
},
|
||||
fx.As(new(article.ArticleApplicationService)),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user