This commit is contained in:
2025-05-09 21:45:15 +08:00
parent 28879b02fb
commit 830d9ae9d9
4 changed files with 274 additions and 92 deletions

View File

@@ -35,17 +35,18 @@ type ServiceContext struct {
ExampleParamsModel model.ExampleParamsModel
// 服务
AlipayService *service.AliPayService
WechatPayService *service.WechatPayService
ApplePayService *service.ApplePayService
WestDexService *service.WestDexService
YushanService *service.YushanService
TianjuService *service.TianjuService
ApiRequestService *service.ApiRequestService
AsynqServer *asynq.Server // 服务端
AsynqService *service.AsynqService // 客户端
VerificationService *service.VerificationService
DictService *service.DictService
AlipayService *service.AliPayService
WechatPayService *service.WechatPayService
ApplePayService *service.ApplePayService
WestDexService *service.WestDexService
YushanService *service.YushanService
TianjuService *service.TianjuService
ApiRequestService *service.ApiRequestService
AsynqServer *asynq.Server // 服务端
AsynqService *service.AsynqService // 客户端
VerificationService *service.VerificationService
DictService *service.DictService
AdminPromotionLinkStatsService *service.AdminPromotionLinkStatsService
// admin
AdminApiModel model.AdminApiModel
@@ -105,35 +106,40 @@ func NewServiceContext(c config.Config) *ServiceContext {
featureModel := model.NewFeatureModel(db, c.CacheRedis)
userAuthModel := model.NewUserAuthModel(db, c.CacheRedis)
apiRequestService := service.NewApiRequestService(c, westDexService, yushanService, tianjuService, featureModel, productFeatureModel)
adminPromotionLinkStatsService := service.NewAdminPromotionLinkStatsService(&service.ServiceContext{
AdminPromotionLinkModel: adminPromotionLinkModel,
AdminPromotionLinkStatsTotalModel: adminPromotionLinkStatsTotalModel,
AdminPromotionLinkStatsHistoryModel: adminPromotionLinkStatsHistoryModel,
})
dictService := service.NewDictService(adminDictTypeModel, adminDictDataModel)
return &ServiceContext{
Config: c,
Redis: redis.MustNewRedis(redisConf),
SourceInterceptor: middleware.NewSourceInterceptorMiddleware().Handle,
AuthInterceptor: middleware.NewAuthInterceptorMiddleware(c).Handle,
AlipayService: service.NewAliPayService(c),
WechatPayService: service.NewWechatPayService(c, userAuthModel),
ApplePayService: service.NewApplePayService(c),
WestDexService: westDexService,
YushanService: yushanService,
TianjuService: tianjuService,
VerificationService: service.NewVerificationService(c, westDexService, apiRequestService),
AsynqServer: asynqServer,
ApiRequestService: apiRequestService,
AsynqService: service.NewAsynqService(c),
DictService: dictService,
UserModel: model.NewUserModel(db, c.CacheRedis),
UserAuthModel: userAuthModel,
ProductModel: model.NewProductModel(db, c.CacheRedis),
ProductRenderModel: model.NewProductRenderModel(db, c.CacheRedis),
OrderModel: model.NewOrderModel(db, c.CacheRedis),
QueryModel: model.NewQueryModel(db, c.CacheRedis),
ExampleModel: model.NewExampleModel(db, c.CacheRedis),
ExampleParamsModel: model.NewExampleParamsModel(db, c.CacheRedis),
GlobalNotificationsModel: model.NewGlobalNotificationsModel(db, c.CacheRedis),
FeatureModel: featureModel,
ProductFeatureModel: productFeatureModel,
Config: c,
Redis: redis.MustNewRedis(redisConf),
SourceInterceptor: middleware.NewSourceInterceptorMiddleware().Handle,
AuthInterceptor: middleware.NewAuthInterceptorMiddleware(c).Handle,
AlipayService: service.NewAliPayService(c),
WechatPayService: service.NewWechatPayService(c, userAuthModel),
ApplePayService: service.NewApplePayService(c),
WestDexService: westDexService,
YushanService: yushanService,
TianjuService: tianjuService,
AdminPromotionLinkStatsService: adminPromotionLinkStatsService,
VerificationService: service.NewVerificationService(c, westDexService, apiRequestService),
AsynqServer: asynqServer,
ApiRequestService: apiRequestService,
AsynqService: service.NewAsynqService(c),
DictService: dictService,
UserModel: model.NewUserModel(db, c.CacheRedis),
UserAuthModel: userAuthModel,
ProductModel: model.NewProductModel(db, c.CacheRedis),
ProductRenderModel: model.NewProductRenderModel(db, c.CacheRedis),
OrderModel: model.NewOrderModel(db, c.CacheRedis),
QueryModel: model.NewQueryModel(db, c.CacheRedis),
ExampleModel: model.NewExampleModel(db, c.CacheRedis),
ExampleParamsModel: model.NewExampleParamsModel(db, c.CacheRedis),
GlobalNotificationsModel: model.NewGlobalNotificationsModel(db, c.CacheRedis),
FeatureModel: featureModel,
ProductFeatureModel: productFeatureModel,
AdminApiModel: adminApiModel,
AdminMenuModel: adminMenuModel,