fix: wire AssetLevelService into existing service constructors

This commit is contained in:
zerosaturation 2026-05-25 12:25:45 +08:00
parent bee30a1824
commit 2a0db41dbf
4 changed files with 1277 additions and 4 deletions

View File

@ -132,11 +132,16 @@ func main() {
userClient := assetClient.NewUserServiceClient(userServiceClient)
logger.Logger.Info("User Service RPC client initialized")
// 创建 Provider 层实例(用于获取 AssetLevelService
assetLevelProvider := provider.NewAssetLevelProvider(database.GetDB())
assetLevelSvc := assetLevelProvider.GetLevelService()
logger.Logger.Info("AssetLevelProvider initialized")
// 创建 Service 层实例
registryRepo := starbookRepo.NewAssetRegistryRepository(database.GetDB())
assetService := service.NewAssetService(assetRepo, mintOrderRepo, assetLikeRepo, userClient, database.GetDB(), registryRepo)
mintService := service.NewMintService(assetRepo, mintOrderRepo, userClient, database.GetDB(), config.GlobalAssetConfig, registryRepo, mintCostRepo, userMintCountRepo)
assetLikeService := service.NewAssetLikeService(assetRepo, assetLikeRepo, database.GetDB())
mintService := service.NewMintService(assetRepo, mintOrderRepo, userClient, database.GetDB(), config.GlobalAssetConfig, registryRepo, mintCostRepo, userMintCountRepo, assetLevelSvc)
assetLikeService := service.NewAssetLikeService(assetRepo, assetLikeRepo, database.GetDB(), assetLevelSvc)
rankingService := service.NewRankingService(rankingRepo, userClient)
materialService := service.NewMaterialService(materialRepo, relationRepo)
logger.Logger.Info("Service layer initialized")

View File

@ -17,6 +17,8 @@ import (
pb "github.com/topfans/backend/pkg/proto/task"
pbGallery "github.com/topfans/backend/pkg/proto/gallery"
pbUser "github.com/topfans/backend/pkg/proto/user"
assetLevelRepo "github.com/topfans/backend/services/assetService/repository"
assetLevelSvc "github.com/topfans/backend/services/assetService/service"
"github.com/topfans/backend/services/taskService/client"
"github.com/topfans/backend/services/taskService/config"
"github.com/topfans/backend/services/taskService/model"
@ -105,9 +107,15 @@ func main() {
logger.Logger.Info("Gallery RPC client initialized")
// 6. Init services
// Create AssetLevelService for revenue calculations
assetLevelRepository := assetLevelRepo.NewAssetLevelRepository(db)
seasonRepository := assetLevelRepo.NewSeasonRepository(db)
seasonDecayConfigRepository := assetLevelRepo.NewSeasonDecayConfigRepository(db)
assetLevelService := assetLevelSvc.NewAssetLevelService(assetLevelRepository, seasonRepository, seasonDecayConfigRepository)
dailySvc := service.NewDailyTaskService(dailyRepo, userRPCClient)
onboardingSvc := service.NewOnboardingService(onboardingRepo, dailyRepo, userRPCClient)
revenueSvc := service.NewRevenueService(revenueRepo, userRPCClient, galleryRPCClient)
revenueSvc := service.NewRevenueService(revenueRepo, userRPCClient, galleryRPCClient, assetLevelService)
logger.Logger.Info("Services initialized")
// 7. Init workergoroutine 中启动)

View File

@ -7,6 +7,7 @@ import (
pbCommon "github.com/topfans/backend/pkg/proto/common"
"github.com/topfans/backend/pkg/logger"
"github.com/topfans/backend/pkg/models"
pb "github.com/topfans/backend/pkg/proto/task"
"github.com/topfans/backend/services/taskService/client"
"github.com/topfans/backend/services/taskService/model"
@ -25,7 +26,7 @@ type RevenueService interface {
// AssetLevelService 资产等级服务接口定义在assetService
type AssetLevelService interface {
GetOrCreateRecord(assetID int64) (interface{}, error)
GetOrCreateRecord(assetID int64) (*models.AssetLevelRecord, error)
AddExhibitionHours(assetID int64, hours int) (string, bool, error)
}

File diff suppressed because it is too large Load Diff