init
This commit is contained in:
+43
-31
@@ -73,6 +73,7 @@ func (a *App) Initialize(cfg *config.Config) error {
|
||||
services.paymentMethodService,
|
||||
validators.paymentMethodValidator,
|
||||
services.analyticsService,
|
||||
services.tableService,
|
||||
)
|
||||
|
||||
return nil
|
||||
@@ -118,40 +119,44 @@ func (a *App) Shutdown() {
|
||||
}
|
||||
|
||||
type repositories struct {
|
||||
userRepo *repository.UserRepositoryImpl
|
||||
organizationRepo *repository.OrganizationRepositoryImpl
|
||||
outletRepo *repository.OutletRepositoryImpl
|
||||
outletSettingRepo *repository.OutletSettingRepositoryImpl
|
||||
categoryRepo *repository.CategoryRepositoryImpl
|
||||
productRepo *repository.ProductRepositoryImpl
|
||||
productVariantRepo *repository.ProductVariantRepositoryImpl
|
||||
inventoryRepo *repository.InventoryRepositoryImpl
|
||||
orderRepo *repository.OrderRepositoryImpl
|
||||
orderItemRepo *repository.OrderItemRepositoryImpl
|
||||
paymentRepo *repository.PaymentRepositoryImpl
|
||||
paymentMethodRepo *repository.PaymentMethodRepositoryImpl
|
||||
fileRepo *repository.FileRepositoryImpl
|
||||
customerRepo *repository.CustomerRepository
|
||||
analyticsRepo *repository.AnalyticsRepositoryImpl
|
||||
userRepo *repository.UserRepositoryImpl
|
||||
organizationRepo *repository.OrganizationRepositoryImpl
|
||||
outletRepo *repository.OutletRepositoryImpl
|
||||
outletSettingRepo *repository.OutletSettingRepositoryImpl
|
||||
categoryRepo *repository.CategoryRepositoryImpl
|
||||
productRepo *repository.ProductRepositoryImpl
|
||||
productVariantRepo *repository.ProductVariantRepositoryImpl
|
||||
inventoryRepo *repository.InventoryRepositoryImpl
|
||||
inventoryMovementRepo *repository.InventoryMovementRepositoryImpl
|
||||
orderRepo *repository.OrderRepositoryImpl
|
||||
orderItemRepo *repository.OrderItemRepositoryImpl
|
||||
paymentRepo *repository.PaymentRepositoryImpl
|
||||
paymentMethodRepo *repository.PaymentMethodRepositoryImpl
|
||||
fileRepo *repository.FileRepositoryImpl
|
||||
customerRepo *repository.CustomerRepository
|
||||
analyticsRepo *repository.AnalyticsRepositoryImpl
|
||||
tableRepo *repository.TableRepository
|
||||
}
|
||||
|
||||
func (a *App) initRepositories() *repositories {
|
||||
return &repositories{
|
||||
userRepo: repository.NewUserRepository(a.db),
|
||||
organizationRepo: repository.NewOrganizationRepositoryImpl(a.db),
|
||||
outletRepo: repository.NewOutletRepositoryImpl(a.db),
|
||||
outletSettingRepo: repository.NewOutletSettingRepositoryImpl(a.db),
|
||||
categoryRepo: repository.NewCategoryRepositoryImpl(a.db),
|
||||
productRepo: repository.NewProductRepositoryImpl(a.db),
|
||||
productVariantRepo: repository.NewProductVariantRepositoryImpl(a.db),
|
||||
inventoryRepo: repository.NewInventoryRepositoryImpl(a.db),
|
||||
orderRepo: repository.NewOrderRepositoryImpl(a.db),
|
||||
orderItemRepo: repository.NewOrderItemRepositoryImpl(a.db),
|
||||
paymentRepo: repository.NewPaymentRepositoryImpl(a.db),
|
||||
paymentMethodRepo: repository.NewPaymentMethodRepositoryImpl(a.db),
|
||||
fileRepo: repository.NewFileRepositoryImpl(a.db),
|
||||
customerRepo: repository.NewCustomerRepository(a.db),
|
||||
analyticsRepo: repository.NewAnalyticsRepositoryImpl(a.db),
|
||||
userRepo: repository.NewUserRepository(a.db),
|
||||
organizationRepo: repository.NewOrganizationRepositoryImpl(a.db),
|
||||
outletRepo: repository.NewOutletRepositoryImpl(a.db),
|
||||
outletSettingRepo: repository.NewOutletSettingRepositoryImpl(a.db),
|
||||
categoryRepo: repository.NewCategoryRepositoryImpl(a.db),
|
||||
productRepo: repository.NewProductRepositoryImpl(a.db),
|
||||
productVariantRepo: repository.NewProductVariantRepositoryImpl(a.db),
|
||||
inventoryRepo: repository.NewInventoryRepositoryImpl(a.db),
|
||||
inventoryMovementRepo: repository.NewInventoryMovementRepositoryImpl(a.db),
|
||||
orderRepo: repository.NewOrderRepositoryImpl(a.db),
|
||||
orderItemRepo: repository.NewOrderItemRepositoryImpl(a.db),
|
||||
paymentRepo: repository.NewPaymentRepositoryImpl(a.db),
|
||||
paymentMethodRepo: repository.NewPaymentMethodRepositoryImpl(a.db),
|
||||
fileRepo: repository.NewFileRepositoryImpl(a.db),
|
||||
customerRepo: repository.NewCustomerRepository(a.db),
|
||||
analyticsRepo: repository.NewAnalyticsRepositoryImpl(a.db),
|
||||
tableRepo: repository.NewTableRepository(a.db),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,6 +174,7 @@ type processors struct {
|
||||
fileProcessor processor.FileProcessor
|
||||
customerProcessor *processor.CustomerProcessor
|
||||
analyticsProcessor *processor.AnalyticsProcessorImpl
|
||||
tableProcessor *processor.TableProcessor
|
||||
}
|
||||
|
||||
func (a *App) initProcessors(cfg *config.Config, repos *repositories) *processors {
|
||||
@@ -183,11 +189,12 @@ func (a *App) initProcessors(cfg *config.Config, repos *repositories) *processor
|
||||
productProcessor: processor.NewProductProcessorImpl(repos.productRepo, repos.categoryRepo, repos.productVariantRepo, repos.inventoryRepo, repos.outletRepo),
|
||||
productVariantProcessor: processor.NewProductVariantProcessorImpl(repos.productVariantRepo, repos.productRepo),
|
||||
inventoryProcessor: processor.NewInventoryProcessorImpl(repos.inventoryRepo, repos.productRepo, repos.outletRepo),
|
||||
orderProcessor: processor.NewOrderProcessorImpl(repos.orderRepo, repos.orderItemRepo, repos.paymentRepo, repos.productRepo, repos.paymentMethodRepo, repos.inventoryRepo, repos.productVariantRepo, repos.outletRepo, repos.customerRepo),
|
||||
orderProcessor: processor.NewOrderProcessorImpl(repos.orderRepo, repos.orderItemRepo, repos.paymentRepo, repos.productRepo, repos.paymentMethodRepo, repos.inventoryRepo, repos.inventoryMovementRepo, repos.productVariantRepo, repos.outletRepo, repos.customerRepo),
|
||||
paymentMethodProcessor: processor.NewPaymentMethodProcessorImpl(repos.paymentMethodRepo),
|
||||
fileProcessor: processor.NewFileProcessorImpl(repos.fileRepo, fileClient),
|
||||
customerProcessor: processor.NewCustomerProcessor(repos.customerRepo),
|
||||
analyticsProcessor: processor.NewAnalyticsProcessorImpl(repos.analyticsRepo),
|
||||
tableProcessor: processor.NewTableProcessor(repos.tableRepo, repos.orderRepo),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,6 +213,7 @@ type services struct {
|
||||
fileService service.FileService
|
||||
customerService service.CustomerService
|
||||
analyticsService *service.AnalyticsServiceImpl
|
||||
tableService *service.TableService
|
||||
}
|
||||
|
||||
func (a *App) initServices(processors *processors, cfg *config.Config) *services {
|
||||
@@ -224,6 +232,7 @@ func (a *App) initServices(processors *processors, cfg *config.Config) *services
|
||||
fileService := service.NewFileServiceImpl(processors.fileProcessor)
|
||||
var customerService service.CustomerService = service.NewCustomerService(processors.customerProcessor)
|
||||
analyticsService := service.NewAnalyticsServiceImpl(processors.analyticsProcessor)
|
||||
tableService := service.NewTableService(processors.tableProcessor, transformer.NewTableTransformer())
|
||||
|
||||
return &services{
|
||||
userService: service.NewUserService(processors.userProcessor),
|
||||
@@ -240,6 +249,7 @@ func (a *App) initServices(processors *processors, cfg *config.Config) *services
|
||||
fileService: fileService,
|
||||
customerService: customerService,
|
||||
analyticsService: analyticsService,
|
||||
tableService: tableService,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,6 +275,7 @@ type validators struct {
|
||||
paymentMethodValidator validator.PaymentMethodValidator
|
||||
fileValidator validator.FileValidator
|
||||
customerValidator validator.CustomerValidator
|
||||
tableValidator *validator.TableValidator
|
||||
}
|
||||
|
||||
func (a *App) initValidators() *validators {
|
||||
@@ -280,5 +291,6 @@ func (a *App) initValidators() *validators {
|
||||
paymentMethodValidator: validator.NewPaymentMethodValidator(),
|
||||
fileValidator: validator.NewFileValidatorImpl(),
|
||||
customerValidator: validator.NewCustomerValidator(),
|
||||
tableValidator: validator.NewTableValidator(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user