开放接口,修复上游同步不对的问题
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m55s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m55s
This commit is contained in:
71
internal/routes/open.go
Normal file
71
internal/routes/open.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
|
||||
openapiHandler "github.com/break/junhong_cmp_fiber/internal/handler/openapi"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/openapi"
|
||||
)
|
||||
|
||||
// RegisterOpenAPIRoutes 注册代理开放接口路由
|
||||
func RegisterOpenAPIRoutes(router fiber.Router, handler *openapiHandler.Handler, doc *openapi.Generator, basePath string) {
|
||||
const tag = "代理开放接口"
|
||||
const authDescription = "认证 Header:X-Agent-Account、X-Agent-Password、X-Agent-Timestamp、X-Agent-Nonce、X-Agent-Sign。签名算法为 hex(HMAC-SHA256(password, sign_payload))。所有启用代理账号默认可调用,不需要开放接口账号授权表。"
|
||||
|
||||
Register(router, doc, basePath, "GET", "/cards/traffic", handler.GetCardTraffic, RouteSpec{
|
||||
Summary: "查询单卡流量",
|
||||
Description: authDescription + "\n\n按 card_no 查询代理权限范围内单卡的当前生效套餐、待生效套餐和真实业务口径流量。不返回虚流量、倍率、停机阈值等内部字段。",
|
||||
Input: new(dto.AgentOpenAPICardQueryRequest),
|
||||
Output: new(dto.AgentOpenAPICardTrafficResponse),
|
||||
Tags: []string{tag},
|
||||
Auth: true,
|
||||
})
|
||||
Register(router, doc, basePath, "GET", "/cards/status", handler.GetCardStatus, RouteSpec{
|
||||
Summary: "查询单卡状态",
|
||||
Description: authDescription + "\n\n按 card_no 查询代理权限范围内单卡状态,network_status=1 返回正常,network_status=0 返回停机和停机原因。",
|
||||
Input: new(dto.AgentOpenAPICardQueryRequest),
|
||||
Output: new(dto.AgentOpenAPICardStatusResponse),
|
||||
Tags: []string{tag},
|
||||
Auth: true,
|
||||
})
|
||||
Register(router, doc, basePath, "GET", "/cards/realname-status", handler.GetRealnameStatus, RouteSpec{
|
||||
Summary: "查询单卡实名状态",
|
||||
Description: authDescription + "\n\n按 card_no 查询代理权限范围内单卡实名状态。",
|
||||
Input: new(dto.AgentOpenAPICardQueryRequest),
|
||||
Output: new(dto.AgentOpenAPIRealnameStatusResponse),
|
||||
Tags: []string{tag},
|
||||
Auth: true,
|
||||
})
|
||||
Register(router, doc, basePath, "GET", "/packages", handler.ListPackages, RouteSpec{
|
||||
Summary: "查询代理套餐列表",
|
||||
Description: authDescription + "\n\n分页查询当前代理已分配、启用、上架且非赠送的可购买套餐,返回代理生效零售价。",
|
||||
Input: new(dto.AgentOpenAPIPackageListRequest),
|
||||
Output: new(dto.AgentOpenAPIPackageItem),
|
||||
Tags: []string{tag},
|
||||
Auth: true,
|
||||
})
|
||||
Register(router, doc, basePath, "POST", "/wallet/package-orders", handler.CreateWalletPackageOrders, RouteSpec{
|
||||
Summary: "钱包套餐购买",
|
||||
Description: authDescription + "\n\n使用代理预充值主钱包为多张卡购买同一个套餐编码。每张卡独立下单,允许部分成功。",
|
||||
Input: new(dto.AgentOpenAPIWalletPackageOrderRequest),
|
||||
Output: new(dto.AgentOpenAPIWalletPackageOrderResponse),
|
||||
Tags: []string{tag},
|
||||
Auth: true,
|
||||
})
|
||||
Register(router, doc, basePath, "GET", "/wallet/balance", handler.GetWalletBalance, RouteSpec{
|
||||
Summary: "查询预充值钱包余额",
|
||||
Description: authDescription + "\n\n查询当前代理预充值主钱包余额。主钱包不存在时返回 0。",
|
||||
Output: new(dto.AgentOpenAPIWalletBalanceResponse),
|
||||
Tags: []string{tag},
|
||||
Auth: true,
|
||||
})
|
||||
Register(router, doc, basePath, "GET", "/wallet/transactions", handler.ListWalletTransactions, RouteSpec{
|
||||
Summary: "查询预充值钱包流水",
|
||||
Description: authDescription + "\n\n分页查询当前代理预充值主钱包流水,字段与后台主钱包流水接口保持一致。",
|
||||
Input: new(dto.AgentOpenAPIWalletTransactionListRequest),
|
||||
Output: new(dto.MainWalletTransactionItem),
|
||||
Tags: []string{tag},
|
||||
Auth: true,
|
||||
})
|
||||
}
|
||||
@@ -32,7 +32,16 @@ func RegisterRoutesWithDoc(app *fiber.App, handlers *bootstrap.Handlers, middlew
|
||||
personalGroup := app.Group("/api/c/v1")
|
||||
RegisterPersonalCustomerRoutes(personalGroup, doc, "/api/c/v1", handlers, middlewares.PersonalAuth)
|
||||
|
||||
// 5. 支付回调路由 (挂载在 /api/callback,无需认证)
|
||||
// 5. 代理开放接口路由 (挂载在 /api/open/v1)
|
||||
if handlers.AgentOpenAPI != nil {
|
||||
openGroup := app.Group("/api/open/v1")
|
||||
if middlewares.AgentOpenAPIAuth != nil {
|
||||
openGroup = app.Group("/api/open/v1", middlewares.AgentOpenAPIAuth)
|
||||
}
|
||||
RegisterOpenAPIRoutes(openGroup, handlers.AgentOpenAPI, doc, "/api/open/v1")
|
||||
}
|
||||
|
||||
// 6. 支付回调路由 (挂载在 /api/callback,无需认证)
|
||||
if handlers.PaymentCallback != nil {
|
||||
callbackGroup := app.Group("/api/callback")
|
||||
registerPaymentCallbackRoutes(callbackGroup, handlers.PaymentCallback, doc, "/api/callback")
|
||||
|
||||
Reference in New Issue
Block a user