mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-28 03:50:25 +08:00
feat: 新增简易版ioc
This commit is contained in:
@@ -2,58 +2,40 @@ package application
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/machine/infrastructure/persistence"
|
||||
tagapp "mayfly-go/internal/tag/application"
|
||||
"mayfly-go/pkg/ioc"
|
||||
)
|
||||
|
||||
var (
|
||||
machineApp Machine = newMachineApp(
|
||||
persistence.GetMachineRepo(),
|
||||
GetAuthCertApp(),
|
||||
tagapp.GetTagTreeApp(),
|
||||
)
|
||||
func init() {
|
||||
persistence.Init()
|
||||
|
||||
machineFileApp MachineFile = newMachineFileApp(
|
||||
persistence.GetMachineFileRepo(),
|
||||
GetMachineApp(),
|
||||
)
|
||||
|
||||
machineScriptApp MachineScript = newMachineScriptApp(
|
||||
persistence.GetMachineScriptRepo(),
|
||||
GetMachineApp(),
|
||||
)
|
||||
|
||||
authCertApp AuthCert = newAuthCertApp(persistence.GetAuthCertRepo())
|
||||
|
||||
machineCropJobApp MachineCronJob = newMachineCronJobApp(
|
||||
persistence.GetMachineCronJobRepo(),
|
||||
persistence.GetMachineCronJobRelateRepo(),
|
||||
persistence.GetMachineCronJobExecRepo(),
|
||||
GetMachineApp(),
|
||||
)
|
||||
|
||||
machineTermOpApp MachineTermOp = newMachineTermOpApp(persistence.GetMachineTermOpRepo())
|
||||
)
|
||||
ioc.Register(new(machineAppImpl), ioc.WithComponentName("MachineApp"))
|
||||
ioc.Register(new(machineFileAppImpl), ioc.WithComponentName("MachineFileApp"))
|
||||
ioc.Register(new(machineScriptAppImpl), ioc.WithComponentName("MachineScriptApp"))
|
||||
ioc.Register(new(authCertAppImpl), ioc.WithComponentName("AuthCertApp"))
|
||||
ioc.Register(new(machineCronJobAppImpl), ioc.WithComponentName("MachineCronJobApp"))
|
||||
ioc.Register(new(machineTermOpAppImpl), ioc.WithComponentName("MachineTermOpApp"))
|
||||
}
|
||||
|
||||
func GetMachineApp() Machine {
|
||||
return machineApp
|
||||
return ioc.Get[Machine]("MachineApp")
|
||||
}
|
||||
|
||||
func GetMachineFileApp() MachineFile {
|
||||
return machineFileApp
|
||||
return ioc.Get[MachineFile]("MachineFileApp")
|
||||
}
|
||||
|
||||
func GetMachineScriptApp() MachineScript {
|
||||
return machineScriptApp
|
||||
return ioc.Get[MachineScript]("MachineScriptApp")
|
||||
}
|
||||
|
||||
func GetAuthCertApp() AuthCert {
|
||||
return authCertApp
|
||||
return ioc.Get[AuthCert]("AuthCertApp")
|
||||
}
|
||||
|
||||
func GetMachineCronJobApp() MachineCronJob {
|
||||
return machineCropJobApp
|
||||
return ioc.Get[MachineCronJob]("MachineCronJobApp")
|
||||
}
|
||||
|
||||
func GetMachineTermOpApp() MachineTermOp {
|
||||
return machineTermOpApp
|
||||
return ioc.Get[MachineTermOp]("MachineTermOpApp")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user