优化结构
This commit is contained in:
@@ -50,6 +50,7 @@ func TestGinRouteContract(t *testing.T) {
|
||||
"GET /integration/configs/:kind/:provider",
|
||||
"PUT /integration/configs/:kind/:provider",
|
||||
"DELETE /integration/configs/:kind/:provider",
|
||||
"POST /payment/providers/:provider/test",
|
||||
} {
|
||||
if !strings.Contains(value, route) {
|
||||
t.Fatalf("route contract missing %s:\n%s", route, value)
|
||||
@@ -70,7 +71,7 @@ func TestGinStartupLogsEveryRegisteredRoute(t *testing.T) {
|
||||
if got, want := strings.Count(text, `"msg":"router registered"`), len(engine.Routes()); got != want {
|
||||
t.Fatalf("registered route log count = %d, want %d", got, want)
|
||||
}
|
||||
if !strings.Contains(text, `"msg":"router register success"`) || !strings.Contains(text, `"route_count":192`) {
|
||||
if !strings.Contains(text, `"msg":"router register success"`) || !strings.Contains(text, `"route_count":193`) {
|
||||
t.Fatalf("startup route summary is missing: %s", text)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,19 @@ func (h *Payment) Orders(c *gin.Context) {
|
||||
}
|
||||
Write(c, CodeSuccess, PageResult{List: items, Total: total, Page: page, PageSize: pageSize}, "获取成功")
|
||||
}
|
||||
|
||||
func (h *Payment) TestProvider(c *gin.Context) {
|
||||
result, err := h.service.TestProvider(c.Request.Context(), c.Param("provider"))
|
||||
if err != nil {
|
||||
if result != nil {
|
||||
Write(c, CodeError, result, err.Error())
|
||||
return
|
||||
}
|
||||
Fail(c, err.Error())
|
||||
return
|
||||
}
|
||||
OKWithData(c, result)
|
||||
}
|
||||
func (h *Payment) Create(c *gin.Context) {
|
||||
var req service.PaymentRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
func RegisterPayment(group, public *gin.RouterGroup, h *Payment) {
|
||||
payment := group.Group("/payment")
|
||||
payment.GET("/orders", h.Orders)
|
||||
payment.POST("/providers/:provider/test", h.TestProvider)
|
||||
payment.POST("/order", h.Order)
|
||||
payment.GET("/orders/:provider/:tradeNo", h.OrderByPath)
|
||||
payment.POST("/create", h.Create)
|
||||
|
||||
Reference in New Issue
Block a user