优化结构
This commit is contained in:
@@ -3,10 +3,8 @@
|
||||
package integration
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
dataintegration "kra/internal/data/integration"
|
||||
"kra/internal/routecatalog"
|
||||
"kra/internal/modules/surface"
|
||||
"kra/pkg/module"
|
||||
)
|
||||
|
||||
@@ -16,18 +14,7 @@ func Definition() module.Definition {
|
||||
Migrations: dataintegration.Migrations(),
|
||||
Surface: module.Surface{
|
||||
Menus: []module.Menu{{Name: "integrationConfig", Path: "integrationConfig", ParentName: "extensions", Component: "view/systemTools/integration/config.vue", Title: "通信集成", Icon: "connection", Sort: 8}},
|
||||
APIs: integrationAPIs(),
|
||||
APIs: surface.APIsForPrefix("/integration/configs", 5),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
package payment
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
datapayment "kra/internal/data/payment"
|
||||
"kra/internal/routecatalog"
|
||||
"kra/internal/modules/surface"
|
||||
"kra/pkg/module"
|
||||
)
|
||||
|
||||
@@ -20,18 +18,7 @@ func Definition() module.Definition {
|
||||
{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: paymentAPIs(),
|
||||
APIs: surface.APIsForPrefix("/payment", 10),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func paymentAPIs() []module.API {
|
||||
items := make([]module.API, 0, 10)
|
||||
for _, descriptor := range routecatalog.Descriptors() {
|
||||
if descriptor.Public || !strings.HasPrefix(descriptor.Path, "/payment") || descriptor.Description == "" {
|
||||
continue
|
||||
}
|
||||
items = append(items, module.API{Path: descriptor.Path, Method: descriptor.Method, Group: descriptor.Group, Description: descriptor.Description})
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package surface
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"kra/internal/routecatalog"
|
||||
"kra/pkg/module"
|
||||
)
|
||||
|
||||
func APIsForPrefix(prefix string, capacity int) []module.API {
|
||||
items := make([]module.API, 0, capacity)
|
||||
for _, descriptor := range routecatalog.Descriptors() {
|
||||
if descriptor.Public || !strings.HasPrefix(descriptor.Path, prefix) || descriptor.Description == "" {
|
||||
continue
|
||||
}
|
||||
items = append(items, module.API{Path: descriptor.Path, Method: descriptor.Method, Group: descriptor.Group, Description: descriptor.Description})
|
||||
}
|
||||
return items
|
||||
}
|
||||
Reference in New Issue
Block a user