Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
113 lines
4.5 KiB
Go
113 lines
4.5 KiB
Go
package routes
|
||
|
||
import (
|
||
"github.com/gofiber/fiber/v2"
|
||
|
||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||
"github.com/break/junhong_cmp_fiber/pkg/openapi"
|
||
)
|
||
|
||
func registerAssetRoutes(router fiber.Router, handler *admin.AssetHandler, walletHandler *admin.AssetWalletHandler, doc *openapi.Generator, basePath string) {
|
||
assets := router.Group("/assets")
|
||
groupPath := basePath + "/assets"
|
||
|
||
Register(assets, doc, groupPath, "GET", "/resolve/:identifier", handler.Resolve, RouteSpec{
|
||
Summary: "解析资产",
|
||
Description: "通过虚拟号/ICCID/IMEI/SN/MSISDN 解析设备或卡的完整详情。企业账号禁止调用。",
|
||
Tags: []string{"资产管理"},
|
||
Input: new(dto.AssetResolveRequest),
|
||
Output: new(dto.AssetResolveResponse),
|
||
Auth: true,
|
||
})
|
||
|
||
Register(assets, doc, groupPath, "GET", "/:asset_type/:id/realtime-status", handler.RealtimeStatus, RouteSpec{
|
||
Summary: "资产实时状态",
|
||
Description: "读取 DB/Redis 中的持久化状态,不调网关。asset_type 为 card 或 device。",
|
||
Tags: []string{"资产管理"},
|
||
Input: new(dto.AssetTypeIDRequest),
|
||
Output: new(dto.AssetRealtimeStatusResponse),
|
||
Auth: true,
|
||
})
|
||
|
||
Register(assets, doc, groupPath, "POST", "/:asset_type/:id/refresh", handler.Refresh, RouteSpec{
|
||
Summary: "刷新资产状态",
|
||
Description: "主动调网关同步最新状态。设备有30秒冷却期。",
|
||
Tags: []string{"资产管理"},
|
||
Input: new(dto.AssetTypeIDRequest),
|
||
Output: new(dto.AssetRealtimeStatusResponse),
|
||
Auth: true,
|
||
})
|
||
|
||
Register(assets, doc, groupPath, "GET", "/:asset_type/:id/packages", handler.Packages, RouteSpec{
|
||
Summary: "资产套餐列表",
|
||
Description: "查询该资产所有套餐记录,含虚流量换算结果。",
|
||
Tags: []string{"资产管理"},
|
||
Input: new(dto.AssetTypeIDRequest),
|
||
Output: new([]dto.AssetPackageResponse),
|
||
Auth: true,
|
||
})
|
||
|
||
Register(assets, doc, groupPath, "GET", "/:asset_type/:id/current-package", handler.CurrentPackage, RouteSpec{
|
||
Summary: "当前生效套餐",
|
||
Tags: []string{"资产管理"},
|
||
Input: new(dto.AssetTypeIDRequest),
|
||
Output: new(dto.AssetPackageResponse),
|
||
Auth: true,
|
||
})
|
||
|
||
Register(assets, doc, groupPath, "POST", "/device/:device_id/stop", handler.StopDevice, RouteSpec{
|
||
Summary: "设备停机",
|
||
Description: "批量停机设备下所有已实名卡。设置1小时停机保护期。",
|
||
Tags: []string{"资产管理"},
|
||
Input: new(dto.DeviceIDRequest),
|
||
Output: new(dto.DeviceSuspendResponse),
|
||
Auth: true,
|
||
})
|
||
|
||
Register(assets, doc, groupPath, "POST", "/device/:device_id/start", handler.StartDevice, RouteSpec{
|
||
Summary: "设备复机",
|
||
Description: "批量复机设备下所有已实名卡。设置1小时复机保护期。",
|
||
Tags: []string{"资产管理"},
|
||
Input: new(dto.DeviceIDRequest),
|
||
Output: nil,
|
||
Auth: true,
|
||
})
|
||
|
||
Register(assets, doc, groupPath, "POST", "/card/:iccid/stop", handler.StopCard, RouteSpec{
|
||
Summary: "单卡停机",
|
||
Description: "手动停机单张卡(通过ICCID)。受设备保护期约束。",
|
||
Tags: []string{"资产管理"},
|
||
Input: new(dto.CardICCIDRequest),
|
||
Output: nil,
|
||
Auth: true,
|
||
})
|
||
|
||
Register(assets, doc, groupPath, "POST", "/card/:iccid/start", handler.StartCard, RouteSpec{
|
||
Summary: "单卡复机",
|
||
Description: "手动复机单张卡(通过ICCID)。受设备保护期约束。",
|
||
Tags: []string{"资产管理"},
|
||
Input: new(dto.CardICCIDRequest),
|
||
Output: nil,
|
||
Auth: true,
|
||
})
|
||
|
||
Register(assets, doc, groupPath, "GET", "/:asset_type/:id/wallet", walletHandler.GetWallet, RouteSpec{
|
||
Summary: "资产钱包概况",
|
||
Description: "查询指定卡或设备的钱包余额概况。企业账号禁止调用。",
|
||
Tags: []string{"资产管理"},
|
||
Input: new(dto.AssetTypeIDRequest),
|
||
Output: new(dto.AssetWalletResponse),
|
||
Auth: true,
|
||
})
|
||
|
||
Register(assets, doc, groupPath, "GET", "/:asset_type/:id/wallet/transactions", walletHandler.ListTransactions, RouteSpec{
|
||
Summary: "资产钱包流水列表",
|
||
Description: "分页查询指定资产的钱包收支流水,含充值/扣款来源编号。企业账号禁止调用。",
|
||
Tags: []string{"资产管理"},
|
||
Input: new(dto.AssetWalletTransactionListRequest),
|
||
Output: new(dto.AssetWalletTransactionListResponse),
|
||
Auth: true,
|
||
})
|
||
}
|