优化结构
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
// Package payment contains the payment module contribution to the application
|
||||
// catalog.
|
||||
package payment
|
||||
|
||||
import (
|
||||
datapayment "kra/internal/data/payment"
|
||||
"kra/pkg/module"
|
||||
)
|
||||
|
||||
// Definition declares the payment-owned schema and administration surface.
|
||||
func Definition() module.Definition {
|
||||
return module.Definition{
|
||||
Name: "payment",
|
||||
Migrations: datapayment.Migrations(),
|
||||
Surface: module.Surface{
|
||||
Menus: []module.Menu{
|
||||
{Name: "paymentOrders", Path: "paymentOrders", ParentName: "extensions", Component: "view/systemTools/payment/orders.vue", Title: "支付订单", Icon: "wallet", Sort: 6},
|
||||
{Name: "paymentConfig", Path: "paymentConfig", ParentName: "extensions", Component: "view/systemTools/payment/config.vue", Title: "支付配置", Icon: "credit-card", Sort: 7},
|
||||
},
|
||||
APIs: []module.API{
|
||||
{Path: "/payment/orders", Method: "GET", Group: "支付", Description: "分页查询支付订单"},
|
||||
{Path: "/payment/order", Method: "POST", Group: "支付", Description: "查询支付订单"},
|
||||
{Path: "/payment/orders/:provider/:tradeNo", Method: "GET", Group: "支付", Description: "按路径查询支付订单"},
|
||||
{Path: "/payment/create", Method: "POST", Group: "支付", Description: "创建支付订单"},
|
||||
{Path: "/payment/query", Method: "POST", Group: "支付", Description: "同步支付订单状态"},
|
||||
{Path: "/payment/refund", Method: "POST", Group: "支付", Description: "申请支付订单退款"},
|
||||
{Path: "/payment/orders/:provider/:tradeNo/refund", Method: "POST", Group: "支付", Description: "按路径申请支付订单退款"},
|
||||
{Path: "/payment/fulfill", Method: "POST", Group: "支付", Description: "重试支付订单发货"},
|
||||
{Path: "/payment/orders/:provider/:tradeNo/fulfill", Method: "POST", Group: "支付", Description: "按路径重试支付订单发货"},
|
||||
{Path: "/payment/providers/:provider/test", Method: "POST", Group: "支付", Description: "测试支付渠道"},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package payment
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestDefinitionOwnsPaymentContributions(t *testing.T) {
|
||||
definition := Definition()
|
||||
if definition.Name != "payment" {
|
||||
t.Fatalf("name = %q, want payment", definition.Name)
|
||||
}
|
||||
if len(definition.Migrations) != 2 {
|
||||
t.Fatalf("migrations = %d, want 2", len(definition.Migrations))
|
||||
}
|
||||
if len(definition.Surface.Menus) != 2 || len(definition.Surface.APIs) != 10 {
|
||||
t.Fatalf("surface = %d menus/%d APIs, want 2/10", len(definition.Surface.Menus), len(definition.Surface.APIs))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// Package system contains the built-in system module contribution to the
|
||||
// application catalog.
|
||||
package system
|
||||
|
||||
import (
|
||||
datasystem "kra/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 {
|
||||
communication := module.Surface{
|
||||
Menus: []module.Menu{{Name: "integrationConfig", Path: "integrationConfig", ParentName: "extensions", Component: "view/systemTools/integration/config.vue", Title: "通信集成", Icon: "connection", Sort: 8}},
|
||||
APIs: []module.API{
|
||||
{Path: "/integration/configs/:kind", Method: "GET", Group: "集成配置", Description: "按类型获取集成配置"},
|
||||
{Path: "/integration/configs/:kind/:provider", Method: "GET", Group: "集成配置", Description: "获取指定集成配置"},
|
||||
{Path: "/integration/configs/:kind/:provider", Method: "PUT", Group: "集成配置", Description: "保存集成配置"},
|
||||
{Path: "/integration/configs/:kind/:provider/test", Method: "POST", Group: "集成配置", Description: "测试通信集成连接"},
|
||||
{Path: "/integration/configs/:kind/:provider", Method: "DELETE", Group: "集成配置", Description: "删除集成配置"},
|
||||
},
|
||||
}
|
||||
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},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user