feat: add asset level provider for dependency injection

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
zerosaturation 2026-05-25 12:17:29 +08:00
parent d88e7ac504
commit c6a8c66e39

View File

@ -0,0 +1,35 @@
package provider
import (
"github.com/topfans/backend/services/assetService/repository"
"github.com/topfans/backend/services/assetService/service"
"github.com/topfans/backend/services/assetService/worker"
"gorm.io/gorm"
)
type AssetLevelProvider struct {
LevelService service.AssetLevelService
db *gorm.DB
}
func NewAssetLevelProvider(db *gorm.DB) *AssetLevelProvider {
levelRepo := repository.NewAssetLevelRepository(db)
seasonRepo := repository.NewSeasonRepository(db)
decayConfigRepo := repository.NewSeasonDecayConfigRepository(db)
levelService := service.NewAssetLevelService(levelRepo, seasonRepo, decayConfigRepo)
return &AssetLevelProvider{
LevelService: levelService,
db: db,
}
}
func (p *AssetLevelProvider) GetLevelService() service.AssetLevelService {
return p.LevelService
}
func (p *AssetLevelProvider) GetSeasonResetWorker() *worker.SeasonResetWorker {
seasonRepo := repository.NewSeasonRepository(p.db)
return worker.NewSeasonResetWorker(seasonRepo, p.LevelService)
}