优化结构
This commit is contained in:
@@ -3,38 +3,15 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
datasystem "kra/internal/data/repository"
|
||||
"kra/internal/routecatalog"
|
||||
datasystem "kra/internal/data/system"
|
||||
"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 {
|
||||
communication := module.Surface{
|
||||
Menus: []module.Menu{{Name: "integrationConfig", Path: "integrationConfig", ParentName: "extensions", Component: "view/systemTools/integration/config.vue", Title: "通信集成", Icon: "connection", Sort: 8}},
|
||||
APIs: integrationAPIs(),
|
||||
}
|
||||
return module.Definition{
|
||||
Name: "system",
|
||||
Migrations: datasystem.Migrations(),
|
||||
Surface: communication,
|
||||
TimedTasks: []module.TimedTask{
|
||||
{Name: "ClearDB", Description: "定时清理数据库过期日志(操作记录/JWT黑名单/定时任务执行日志)", Spec: "@daily", MethodName: "ClearDB", Enabled: true},
|
||||
{Name: "CleanStaleUploads", Description: "定时清理过期大文件上传会话", Spec: "@hourly", MethodName: "CleanStaleUploads", Enabled: true},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func integrationAPIs() []module.API {
|
||||
items := make([]module.API, 0, 5)
|
||||
for _, descriptor := range routecatalog.Descriptors() {
|
||||
if descriptor.Public || !strings.HasPrefix(descriptor.Path, "/integration/configs") || descriptor.Description == "" {
|
||||
continue
|
||||
}
|
||||
items = append(items, module.API{Path: descriptor.Path, Method: descriptor.Method, Group: descriptor.Group, Description: descriptor.Description})
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
@@ -2,26 +2,9 @@ package system
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestDefinitionIncludesCommunicationIntegrationSurface(t *testing.T) {
|
||||
surface := Definition().Surface
|
||||
menuFound := false
|
||||
for _, menu := range surface.Menus {
|
||||
if menu.Name == "integrationConfig" {
|
||||
menuFound = menu.ParentName == "extensions" && menu.Component == "view/systemTools/integration/config.vue"
|
||||
break
|
||||
}
|
||||
}
|
||||
if !menuFound {
|
||||
t.Fatal("communication integration menu is missing")
|
||||
}
|
||||
apiFound := false
|
||||
for _, api := range surface.APIs {
|
||||
if api.Method == "PUT" && api.Path == "/integration/configs/:kind/:provider" {
|
||||
apiFound = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !apiFound {
|
||||
t.Fatal("communication integration save API is missing")
|
||||
func TestDefinitionOwnsOnlySystemMigrations(t *testing.T) {
|
||||
definition := Definition()
|
||||
if definition.Name != "system" || len(definition.Surface.Menus) != 0 || len(definition.Surface.APIs) != 0 {
|
||||
t.Fatalf("system definition = %#v", definition)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user