优化结构
This commit is contained in:
@@ -13,13 +13,14 @@ import (
|
||||
// TaskMethods is the system module's dependency-bearing task contribution.
|
||||
// Other modules provide their own contributor instead of editing this file.
|
||||
type TaskMethods struct {
|
||||
tasks *taskbiz.TaskUsecase
|
||||
media *system.MediaUsecase
|
||||
runtime *conf.Runtime
|
||||
tasks *taskbiz.TaskUsecase
|
||||
maintenance *system.MaintenanceUsecase
|
||||
media *system.MediaUsecase
|
||||
runtime *conf.Runtime
|
||||
}
|
||||
|
||||
func NewTaskMethods(tasks *taskbiz.TaskUsecase, media *system.MediaUsecase, runtime *conf.Runtime) *TaskMethods {
|
||||
return &TaskMethods{tasks: tasks, media: media, runtime: runtime}
|
||||
func NewTaskMethods(tasks *taskbiz.TaskUsecase, maintenance *system.MaintenanceUsecase, media *system.MediaUsecase, runtime *conf.Runtime) *TaskMethods {
|
||||
return &TaskMethods{tasks: tasks, maintenance: maintenance, media: media, runtime: runtime}
|
||||
}
|
||||
|
||||
var _ platformtask.Contributor = (*TaskMethods)(nil)
|
||||
@@ -30,6 +31,9 @@ func (methods *TaskMethods) RegisterTasks(registry *platformtask.Registry) {
|
||||
}
|
||||
registry.Register(platformtask.Method{
|
||||
Name: taskbiz.TaskMethodClearDB, Description: "清理数据库过期日志(操作记录/JWT黑名单/定时任务执行日志)", Run: func(ctx context.Context, _ json.RawMessage) error {
|
||||
if err := methods.maintenance.CleanupExpired(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return methods.tasks.CleanupLogs(ctx)
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user