feat: 数据库迁移至文件支持文件保存天数等

This commit is contained in:
meilin.huang
2024-10-22 20:39:44 +08:00
parent ea3c70a8a8
commit 44a1bd626e
19 changed files with 1043 additions and 1041 deletions

View File

@@ -1,7 +1,13 @@
package application
import (
"context"
"mayfly-go/internal/event"
"mayfly-go/internal/machine/domain/entity"
"mayfly-go/pkg/eventbus"
"mayfly-go/pkg/global"
"mayfly-go/pkg/ioc"
"sync"
)
func InitIoc() {
@@ -13,6 +19,26 @@ func InitIoc() {
ioc.Register(new(machineCmdConfAppImpl), ioc.WithComponentName("MachineCmdConfApp"))
}
func Init() {
sync.OnceFunc(func() {
GetMachineCronJobApp().InitCronJob()
GetMachineApp().TimerUpdateStats()
GetMachineTermOpApp().TimerDeleteTermOp()
global.EventBus.Subscribe(event.EventTopicDeleteMachine, "machineFile", func(ctx context.Context, event *eventbus.Event) error {
me := event.Val.(*entity.Machine)
return GetMachineFileApp().DeleteByCond(ctx, &entity.MachineFile{MachineId: me.Id})
})
global.EventBus.Subscribe(event.EventTopicDeleteMachine, "machineScript", func(ctx context.Context, event *eventbus.Event) error {
me := event.Val.(*entity.Machine)
return GetMachineScriptApp().DeleteByCond(ctx, &entity.MachineScript{MachineId: me.Id})
})
})()
}
func GetMachineApp() Machine {
return ioc.Get[Machine]("MachineApp")
}