Files
junhong_cmp_fiber/internal/routes/polling_config.go
邹进 2ddaffe373
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m57s
docs: 轮询配置接口文档与实际行为对齐
- 匹配预览 GET 只收 query iccid,POST 只收请求体,去掉 POST 文档中多余的 query 参数
- 预览草稿 overrides 改为独立结构,字段全部可选,最多 20 条
- clear_fields 用具名类型生成数组元素枚举;ordered_ids 说明须为正整数且不重复
2026-10-24 17:41:52 +09:00

128 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"
)
// registerPollingConfigRoutes 注册轮询配置管理路由
func registerPollingConfigRoutes(router fiber.Router, handler *admin.PollingConfigHandler, doc *openapi.Generator, basePath string) {
configs := router.Group("/polling-configs")
groupPath := basePath + "/polling-configs"
Register(configs, doc, groupPath, "GET", "", handler.List, RouteSpec{
Summary: "获取轮询配置列表",
Tags: []string{"轮询配置管理"},
Input: new(dto.PollingConfigListRequest),
Output: new(dto.PollingConfigPageResult),
Auth: true,
})
Register(configs, doc, groupPath, "POST", "", handler.Create, RouteSpec{
Summary: "创建轮询配置",
Tags: []string{"轮询配置管理"},
Input: new(dto.CreatePollingConfigRequest),
Output: new(dto.PollingConfigResponse),
Auth: true,
})
Register(configs, doc, groupPath, "GET", "/enabled", handler.ListEnabled, RouteSpec{
Summary: "获取所有启用的配置",
Tags: []string{"轮询配置管理"},
Input: nil,
Output: []dto.PollingConfigResponse{},
Auth: true,
})
Register(configs, doc, groupPath, "PUT", "/priorities", handler.UpdatePriorities, RouteSpec{
Summary: "整体调整轮询配置优先级(仅超级管理员)",
Tags: []string{"轮询配置管理"},
Input: new(dto.UpdatePollingConfigPrioritiesRequest),
Output: nil,
Auth: true,
})
Register(configs, doc, groupPath, "GET", "/match-preview", handler.MatchPreview, RouteSpec{
Summary: "预览卡的轮询配置匹配结果(按当前配置)",
Tags: []string{"轮询配置管理"},
Input: new(dto.PollingConfigMatchPreviewQuery),
Output: new(dto.PollingConfigMatchPreviewResponse),
Auth: true,
})
Register(configs, doc, groupPath, "POST", "/match-preview", handler.MatchPreview, RouteSpec{
Summary: "预览卡的轮询配置匹配结果(可带未保存修改,不写数据)",
Tags: []string{"轮询配置管理"},
Input: new(dto.PollingConfigMatchPreviewRequest),
Output: new(dto.PollingConfigMatchPreviewResponse),
Auth: true,
})
Register(configs, doc, groupPath, "POST", "/recalculate-due", handler.CreateRecalculateTask, RouteSpec{
Summary: "立即重算轮询到期时间(异步,只提前不推后,仅超级管理员)",
Tags: []string{"轮询配置管理"},
Input: new(dto.PollingRecalculateDueRequest),
Output: new(dto.PollingRecalculateDueResponse),
Auth: true,
})
Register(configs, doc, groupPath, "GET", "/recalculate-due/:task_id", handler.GetRecalculateTask, RouteSpec{
Summary: "查询重算轮询到期时间任务进度",
Tags: []string{"轮询配置管理"},
Input: new(dto.PollingRecalculateDueTaskIDRequest),
Output: new(dto.PollingRecalculateDueResponse),
Auth: true,
})
Register(router, doc, basePath, "GET", "/polling-stats/pre-reset", handler.PreResetStats, RouteSpec{
Summary: "重置日前加密查流量效果统计",
Tags: []string{"轮询配置管理"},
Input: nil,
Output: new(dto.PollingPreResetStatsResponse),
Auth: true,
})
Register(router, doc, basePath, "GET", "/polling-stats/tiers", handler.TierStats, RouteSpec{
Summary: "分层轮询统计(结果缓存 5 分钟)",
Tags: []string{"轮询配置管理"},
Input: nil,
Output: new(dto.PollingTierStatsResponse),
Auth: true,
})
Register(configs, doc, groupPath, "GET", "/:id", handler.Get, RouteSpec{
Summary: "获取轮询配置详情",
Tags: []string{"轮询配置管理"},
Input: new(dto.IDReq),
Output: new(dto.PollingConfigResponse),
Auth: true,
})
Register(configs, doc, groupPath, "PUT", "/:id", handler.Update, RouteSpec{
Summary: "更新轮询配置",
Tags: []string{"轮询配置管理"},
Input: new(dto.UpdatePollingConfigParams),
Output: new(dto.PollingConfigResponse),
Auth: true,
})
Register(configs, doc, groupPath, "DELETE", "/:id", handler.Delete, RouteSpec{
Summary: "删除轮询配置",
Tags: []string{"轮询配置管理"},
Input: new(dto.IDReq),
Output: nil,
Auth: true,
})
Register(configs, doc, groupPath, "PUT", "/:id/status", handler.UpdateStatus, RouteSpec{
Summary: "更新轮询配置状态",
Tags: []string{"轮询配置管理"},
Input: new(dto.UpdatePollingConfigStatusParams),
Output: nil,
Auth: true,
})
}