实现配方领域的web接口
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
domain_notify "git.huangwc.com/pig/pig-farm-controller/internal/domain/notify"
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/domain/pig"
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/domain/plan"
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/domain/recipe"
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/domain/task"
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/infra/config"
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/infra/database"
|
||||
@@ -82,6 +83,9 @@ type Repositories struct {
|
||||
medicationLogRepo repository.MedicationLogRepository
|
||||
notificationRepo repository.NotificationRepository
|
||||
alarmRepo repository.AlarmRepository
|
||||
pigTypeRepo repository.PigTypeRepository
|
||||
rawMaterialRepo repository.RawMaterialRepository
|
||||
nutrientRepo repository.NutrientRepository
|
||||
unitOfWork repository.UnitOfWork
|
||||
}
|
||||
|
||||
@@ -110,6 +114,9 @@ func initRepositories(ctx context.Context, db *gorm.DB) *Repositories {
|
||||
medicationLogRepo: repository.NewGormMedicationLogRepository(logs.AddCompName(baseCtx, "MedicationLogRepo"), db),
|
||||
notificationRepo: repository.NewGormNotificationRepository(logs.AddCompName(baseCtx, "NotificationRepo"), db),
|
||||
alarmRepo: repository.NewGormAlarmRepository(logs.AddCompName(baseCtx, "AlarmRepo"), db),
|
||||
pigTypeRepo: repository.NewGormPigTypeRepository(logs.AddCompName(baseCtx, "PigTypeRepo"), db),
|
||||
rawMaterialRepo: repository.NewGormRawMaterialRepository(logs.AddCompName(baseCtx, "RawMaterialRepo"), db),
|
||||
nutrientRepo: repository.NewGormNutrientRepository(logs.AddCompName(baseCtx, "NutrientRepo"), db),
|
||||
unitOfWork: repository.NewGormUnitOfWork(logs.AddCompName(baseCtx, "UnitOfWork"), db),
|
||||
}
|
||||
}
|
||||
@@ -127,6 +134,7 @@ type DomainServices struct {
|
||||
planService plan.Service
|
||||
notifyService domain_notify.Service
|
||||
alarmService alarm.AlarmService
|
||||
recipeService recipe.Service
|
||||
}
|
||||
|
||||
// initDomainServices 初始化所有的领域服务。
|
||||
@@ -206,6 +214,14 @@ func initDomainServices(ctx context.Context, cfg *config.Config, infra *Infrastr
|
||||
taskFactory,
|
||||
)
|
||||
|
||||
// 配方管理服务
|
||||
recipeService := recipe.NewRecipeService(
|
||||
logs.AddCompName(baseCtx, "RecipeService"),
|
||||
infra.repos.nutrientRepo,
|
||||
infra.repos.rawMaterialRepo,
|
||||
infra.repos.pigTypeRepo,
|
||||
)
|
||||
|
||||
return &DomainServices{
|
||||
pigPenTransferManager: pigPenTransferManager,
|
||||
pigTradeManager: pigTradeManager,
|
||||
@@ -218,6 +234,7 @@ func initDomainServices(ctx context.Context, cfg *config.Config, infra *Infrastr
|
||||
planService: planService,
|
||||
notifyService: notifyService,
|
||||
alarmService: alarmService,
|
||||
recipeService: recipeService,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -231,6 +248,7 @@ type AppServices struct {
|
||||
userService service.UserService
|
||||
auditService service.AuditService
|
||||
thresholdAlarmService service.ThresholdAlarmService
|
||||
feedManagementService service.FeedManagementService
|
||||
}
|
||||
|
||||
// initAppServices 初始化所有的应用服务。
|
||||
@@ -278,6 +296,7 @@ func initAppServices(ctx context.Context, infra *Infrastructure, domainServices
|
||||
auditService := service.NewAuditService(logs.AddCompName(baseCtx, "AuditService"), infra.repos.userActionLogRepo)
|
||||
planService := service.NewPlanService(logs.AddCompName(baseCtx, "AppPlanService"), domainServices.planService)
|
||||
userService := service.NewUserService(logs.AddCompName(baseCtx, "UserService"), infra.repos.userRepo, infra.tokenGenerator, domainServices.notifyService)
|
||||
feedManagementService := service.NewFeedManagementService(logs.AddCompName(baseCtx, "FeedManagementService"), domainServices.recipeService)
|
||||
|
||||
return &AppServices{
|
||||
pigFarmService: pigFarmService,
|
||||
@@ -288,6 +307,7 @@ func initAppServices(ctx context.Context, infra *Infrastructure, domainServices
|
||||
planService: planService,
|
||||
userService: userService,
|
||||
thresholdAlarmService: thresholdAlarmService,
|
||||
feedManagementService: feedManagementService,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user