Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
卡流量计量(按名单灰度,默认 off): - 新增卡日快照与切换水位表(000241),按通道上游流量重置日换算自然月、重置日防旧值 - 已切换的卡按月对账产生增量,无生效中套餐只结算不发事件;第一次切换写水位 - 已切换卡读数有效即判定通道阈值,卡表本月用量用快照覆盖,日流量读快照 - 配置 JUNHONG_TRAFFIC_CALC_MODE/CARDS、JUNHONG_TRAFFIC_FLOW_SNAPSHOT_ENABLED 停复机规则(总开关 JUNHONG_STOP_RESUME_UNIFIED_RULE_ENABLED,默认关闭): - 复机不看停机原因,持通道阈值锁仍拒绝;暂停轮询的卡不自动停复机 - 通道新增实名管控 realname_control_enabled(000242,默认 0),开启后不区分行业卡与实名策略 - 实名管控从 0 改 1 需确认,修改并入通道更新审计 OpenSpec Change: rebuild-card-traffic-metering-and-stop-resume
98 lines
4.1 KiB
Go
98 lines
4.1 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/constants"
|
||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||
"github.com/break/junhong_cmp_fiber/pkg/middleware"
|
||
"github.com/break/junhong_cmp_fiber/pkg/openapi"
|
||
)
|
||
|
||
func registerCarrierRoutes(router fiber.Router, handler *admin.CarrierHandler, doc *openapi.Generator, basePath string) {
|
||
// 通道阈值命中记录使用顶层路径,避免与 /carriers/:id 的参数路由冲突;
|
||
// 门禁沿用超管/平台路由组级 gate 先例(代理、企业与其他账号统一 403),
|
||
// 并挂在功能路径组上:Fiber 的组中间件按路径前缀生效。
|
||
hitGate := func(c *fiber.Ctx) error {
|
||
userType := middleware.GetUserTypeFromContext(c.UserContext())
|
||
if userType != constants.UserTypeSuperAdmin && userType != constants.UserTypePlatform {
|
||
return errors.New(errors.CodeForbidden, constants.PlatformManagementForbiddenMessage)
|
||
}
|
||
return c.Next()
|
||
}
|
||
|
||
hits := router.Group("/carrier-traffic-threshold-hits", hitGate)
|
||
hitsPath := basePath + "/carrier-traffic-threshold-hits"
|
||
|
||
Register(hits, doc, hitsPath, "GET", "", handler.ListThresholdHits, RouteSpec{
|
||
Summary: "查询通道阈值命中记录",
|
||
Description: "返回达量停机时冻结的数字证据:命中时该卡当前周期的累计流量读数、本次判定实际生效的阈值与单位、" +
|
||
"计费周期起点、判定时间与触发来源,以及周期恢复的解锁时间与复机结果;" +
|
||
"阈值与读数为命中时值,之后修改通道阈值不改写历史命中;" +
|
||
"本次上线前的历史行读数为空按「无」返回,判定时间取既有创建时间,不阻断查询。" +
|
||
"支持按运营商通道、卡、计费周期起点精确匹配与判定时间闭区间(start_time/end_time,带时区 RFC3339 秒级)筛选," +
|
||
"按判定时间倒序分页;仅超级管理员与平台账号可访问,并按卡数据范围过滤,越权与不存在不可区分," +
|
||
"不返回凭证或上游响应原文",
|
||
Tags: []string{"运营商管理"},
|
||
Input: new(dto.CarrierThresholdHitListRequest),
|
||
Output: new(dto.CarrierThresholdHitPageResult),
|
||
Auth: true,
|
||
})
|
||
|
||
carriers := router.Group("/carriers")
|
||
groupPath := basePath + "/carriers"
|
||
|
||
Register(carriers, doc, groupPath, "GET", "", handler.List, RouteSpec{
|
||
Summary: "运营商列表",
|
||
Tags: []string{"运营商管理"},
|
||
Input: new(dto.CarrierListRequest),
|
||
Output: new(dto.CarrierPageResult),
|
||
Auth: true,
|
||
})
|
||
|
||
Register(carriers, doc, groupPath, "POST", "", handler.Create, RouteSpec{
|
||
Summary: "创建运营商",
|
||
Tags: []string{"运营商管理"},
|
||
Input: new(dto.CreateCarrierRequest),
|
||
Output: new(dto.CarrierResponse),
|
||
Auth: true,
|
||
})
|
||
|
||
Register(carriers, doc, groupPath, "GET", "/:id", handler.Get, RouteSpec{
|
||
Summary: "获取运营商详情",
|
||
Tags: []string{"运营商管理"},
|
||
Input: new(dto.IDReq),
|
||
Output: new(dto.CarrierResponse),
|
||
Auth: true,
|
||
})
|
||
|
||
Register(carriers, doc, groupPath, "PUT", "/:id", handler.Update, RouteSpec{
|
||
Summary: "更新运营商",
|
||
Description: "通道流量阈值与通道实名管控(realname_control_enabled)仅超级管理员与平台账号可修改,非平台账号携带即整体拒绝;" +
|
||
"实名管控从 0 改为 1 时必须携带 realname_control_confirm=true,未确认时返回该通道未实名开机卡数且不保存;" +
|
||
"修改并入运营商更新审计",
|
||
Tags: []string{"运营商管理"},
|
||
Input: new(dto.UpdateCarrierParams),
|
||
Output: new(dto.CarrierResponse),
|
||
Auth: true,
|
||
})
|
||
|
||
Register(carriers, doc, groupPath, "DELETE", "/:id", handler.Delete, RouteSpec{
|
||
Summary: "删除运营商",
|
||
Tags: []string{"运营商管理"},
|
||
Input: new(dto.IDReq),
|
||
Output: nil,
|
||
Auth: true,
|
||
})
|
||
|
||
Register(carriers, doc, groupPath, "PUT", "/:id/status", handler.UpdateStatus, RouteSpec{
|
||
Summary: "更新运营商状态",
|
||
Tags: []string{"运营商管理"},
|
||
Input: new(dto.UpdateCarrierStatusParams),
|
||
Output: nil,
|
||
Auth: true,
|
||
})
|
||
}
|