Files
junhong_cmp_fiber/internal/routes/carrier_scheduler.go
邹进 f6a740b9f3
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m30s
docs: 告警处理接口说明指向告警页批量关闭轮询
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 10:06:14 +09:00

72 lines
5.5 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"
"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"
)
// registerCarrierSchedulerRoutes 注册按运营商账户调度的后台接口。读取仅超级管理员与平台账号,修改仅超级管理员(服务层校验)。
func registerCarrierSchedulerRoutes(router fiber.Router, handler *admin.CarrierSchedulerHandler, doc *openapi.Generator, basePath string) {
tags := []string{"轮询调度"}
params := router.Group("/polling-carrier-params")
paramsPath := basePath + "/polling-carrier-params"
Register(params, doc, paramsPath, "GET", "", handler.ListParams, RouteSpec{
Summary: "查询运营商账户调度参数列表", Description: "未单独配置的账户返回全局默认并标记 is_default。", Tags: tags,
Input: nil, Output: new(dto.CarrierPollingParamListResponse), Auth: true,
})
Register(params, doc, paramsPath, "GET", "/:carrier_id", handler.GetParam, RouteSpec{
Summary: "查询运营商账户调度参数", Tags: tags, Input: new(dto.CarrierPollingParamPath), Output: new(dto.CarrierPollingParamItem), Auth: true,
})
Register(params, doc, paramsPath, "PUT", "/:carrier_id", handler.SaveParam, RouteSpec{
Summary: "保存运营商账户调度参数(仅超级管理员)",
Description: "字段为空表示该项使用全局默认;执行上限不得大于当前订阅进程 max_in_flight 之和;下一轮调度生效并写统一审计。",
Tags: tags, Input: new(dto.SaveCarrierPollingParamRequest), Output: new(dto.CarrierPollingParamItem), Auth: true,
})
Register(params, doc, paramsPath, "DELETE", "/:carrier_id", handler.DeleteParam, RouteSpec{
Summary: "删除运营商账户调度参数(恢复全局默认,仅超级管理员)", Tags: tags, Input: new(dto.CarrierPollingParamPath), Output: nil, Auth: true,
})
scenes := router.Group("/polling-check-scenes")
scenesPath := basePath + "/polling-check-scenes"
Register(scenes, doc, scenesPath, "GET", "", handler.ListScenes, RouteSpec{
Summary: "查询请求检查场景", Description: "业务事件与读入口在按运营商账户调度时按场景请求检查;场景由代码预置。", Tags: tags,
Input: nil, Output: new([]dto.PollingCheckSceneItem), Auth: true,
})
Register(scenes, doc, scenesPath, "PUT", "/:scene", handler.UpdateScene, RouteSpec{
Summary: "修改请求检查场景(仅超级管理员)", Description: "只可修改检查类型、延迟确认序列(递增)与冷却时长。", Tags: tags,
Input: new(dto.UpdatePollingCheckSceneRequest), Output: new(dto.PollingCheckSceneItem), Auth: true,
})
alerts := router.Group("/polling-failure-alerts")
alertsPath := basePath + "/polling-failure-alerts"
Register(alerts, doc, alertsPath, "GET", "", handler.ListAlerts, RouteSpec{
Summary: "查询卡轮询失败告警列表",
Description: "view=stop_refused 为停机被拒视图:停复机方向为停机,且错误类型为终态或业务错误、或停机失败次数达到停复机告警阈值;该视图只按 carrier_id、status、iccid、start_time、end_time 筛选(忽略 check_type、error_category、alert_level)," +
"并额外返回 device_id、network_status、stop_reason、enable_polling、has_package、handled_by_name。导出使用统一导出任务,场景 polling_stop_refused_alert。",
Tags: tags, Input: new(dto.PollingFailureAlertListRequest), Output: new(dto.PollingFailureAlertPageResult), Auth: true,
})
Register(alerts, doc, alertsPath, "GET", "/summary", handler.AlertSummary, RouteSpec{
Summary: "未处理卡轮询失败告警按运营商账户与错误类别汇总", Tags: tags, Input: nil, Output: new([]dto.PollingFailureAlertSummaryItem), Auth: true,
})
Register(alerts, doc, alertsPath, "GET", "/:id", handler.GetAlert, RouteSpec{
Summary: "查询卡轮询失败告警详情", Tags: tags, Input: new(dto.PollingFailureAlertIDPath), Output: new(dto.PollingFailureAlertItem), Auth: true,
})
Register(alerts, doc, alertsPath, "PUT", "/:id/status", handler.HandleAlert, RouteSpec{
Summary: "标记卡轮询失败告警已处理", Description: "只有未处理告警可标记;需要关闭对应卡的轮询时使用 POST /polling-failure-alerts/close-polling(告警状态自动改为已关闭轮询)。", Tags: tags,
Input: new(dto.HandlePollingFailureAlertRequest), Output: nil, Auth: true,
})
Register(router, doc, basePath, "GET", "/iot-cards/:id/polling-state", handler.CardState, RouteSpec{
Summary: "查询单卡轮询状态", Description: "各检查类型下次到期、最近成功、连续失败与最近错误、是否执行中;停复机出口开关、当前停复机指令(动作、原因、场景、版本、失败次数、待确认、下次可执行时间)与最近一次停复机调用时间;只读。", Tags: tags,
Input: new(dto.CardPollingStatePath), Output: new(dto.CardPollingStateResponse), Auth: true,
})
Register(router, doc, basePath, "GET", "/polling-stats/carrier-queues", handler.CarrierStats, RouteSpec{
Summary: "按运营商账户的轮询队列与执行监控", Description: "按运营商账户调度的各账户队列长度、已到期数、执行中、上一分钟 QPS、限流等待与拒绝、处理中标记到期、未处理告警;停复机指令队列长度、已到期、执行中、待确认,近 1 小时停复机成功、失败、重试、结果未知数。", Tags: tags,
Input: nil, Output: new(dto.CarrierPollingStatsResponse), Auth: true,
})
}