Files
junhong_cmp_fiber/internal/routes/open.go
huang 98ff88d5c3
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m55s
开放接口,修复上游同步不对的问题
2026-05-11 11:20:48 +08:00

72 lines
3.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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 = "认证 HeaderX-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,
})
}