优化结构

This commit is contained in:
Yvan
2026-08-21 08:54:29 +08:00
parent c968f9f24e
commit 77e192b6c0
167 changed files with 3657 additions and 1528 deletions
+3 -4
View File
@@ -4,8 +4,7 @@
package app
import (
systemmodule "kra/app/system/internal/module"
systemserver "kra/app/system/internal/server"
systemrouter "kra/app/system/internal/server/router"
systemworker "kra/app/system/internal/worker"
"kra/pkg/module"
platformtask "kra/pkg/task"
@@ -15,7 +14,7 @@ import (
// module means adding one Definition here; system initialization and runtime
// code consume the catalog without knowing that module's implementation.
func Catalog() module.Catalog {
return module.Catalog{Definitions: []module.Definition{systemmodule.Definition()}}
return module.Catalog{Definitions: []module.Definition{Definition()}}
}
// TaskRegistry builds the process-wide registry from dependency-free module
@@ -28,7 +27,7 @@ func TaskRegistry(catalog module.Catalog) *platformtask.Registry {
}
// Runtime composes HTTP route contributors from the enabled modules.
func Runtime(systemRoutes *systemserver.Routes, systemTasks *systemworker.TaskMethods, registry *platformtask.Registry) *module.Runtime {
func Runtime(systemRoutes *systemrouter.Routes, systemTasks *systemworker.TaskMethods, registry *platformtask.Registry) *module.Runtime {
platformtask.Apply(registry, systemTasks)
return module.NewRuntime(systemRoutes)
}
+21
View File
@@ -0,0 +1,21 @@
package app
import (
datapayment "kra/app/system/internal/data/payment"
datasystem "kra/app/system/internal/data/repository"
"kra/pkg/module"
)
// Definition describes the built-in system contribution to the application
// catalog. Other business modules can expose the same shape independently.
func Definition() module.Definition {
return module.Definition{
Name: "system",
Migrations: append(datasystem.Migrations(), datapayment.Migrations()...),
Surface: datapayment.AdminSurface(),
TimedTasks: []module.TimedTask{
{Name: "ClearDB", Description: "定时清理数据库过期日志(操作记录/JWT黑名单/定时任务执行日志)", Spec: "@daily", MethodName: "ClearDB", Enabled: true},
{Name: "CleanStaleUploads", Description: "定时清理过期大文件上传会话", Spec: "@hourly", MethodName: "CleanStaleUploads", Enabled: true},
},
}
}