All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m12s
1. CountOldRecords 改用 GORM .Scan() 替代 .Row().Scan(),避免查询不存在的表时 nil pointer panic 2. polling_cleanup 路由注册的 basePath 参数去掉多余拼接,修复生成的 OpenAPI 文档路径翻倍
91 lines
2.9 KiB
Go
91 lines
2.9 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"
|
|
)
|
|
|
|
// registerPollingCleanupRoutes 注册轮询数据清理路由
|
|
func registerPollingCleanupRoutes(router fiber.Router, handler *admin.PollingCleanupHandler, doc *openapi.Generator, basePath string) {
|
|
// 清理配置管理
|
|
configs := router.Group("/data-cleanup-configs")
|
|
configsPath := basePath + "/data-cleanup-configs"
|
|
|
|
Register(configs, doc, configsPath, "POST", "", handler.CreateConfig, RouteSpec{
|
|
Summary: "创建数据清理配置",
|
|
Tags: []string{"轮询管理-数据清理"},
|
|
Input: new(dto.CreateDataCleanupConfigReq),
|
|
Output: new(dto.DataCleanupConfigResp),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(configs, doc, configsPath, "GET", "", handler.ListConfigs, RouteSpec{
|
|
Summary: "获取数据清理配置列表",
|
|
Tags: []string{"轮询管理-数据清理"},
|
|
Input: nil,
|
|
Output: new(dto.DataCleanupConfigListResp),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(configs, doc, configsPath, "GET", "/:id", handler.GetConfig, RouteSpec{
|
|
Summary: "获取数据清理配置详情",
|
|
Tags: []string{"轮询管理-数据清理"},
|
|
Input: new(dto.IDReq),
|
|
Output: new(dto.DataCleanupConfigResp),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(configs, doc, configsPath, "PUT", "/:id", handler.UpdateConfig, RouteSpec{
|
|
Summary: "更新数据清理配置",
|
|
Tags: []string{"轮询管理-数据清理"},
|
|
Input: new(dto.UpdateDataCleanupConfigParams),
|
|
Output: nil,
|
|
Auth: true,
|
|
})
|
|
|
|
Register(configs, doc, configsPath, "DELETE", "/:id", handler.DeleteConfig, RouteSpec{
|
|
Summary: "删除数据清理配置",
|
|
Tags: []string{"轮询管理-数据清理"},
|
|
Input: new(dto.IDReq),
|
|
Output: nil,
|
|
Auth: true,
|
|
})
|
|
|
|
// 清理日志
|
|
Register(router, doc, basePath, "GET", "/data-cleanup-logs", handler.ListLogs, RouteSpec{
|
|
Summary: "获取数据清理日志列表",
|
|
Tags: []string{"轮询管理-数据清理"},
|
|
Input: new(dto.ListDataCleanupLogReq),
|
|
Output: new(dto.DataCleanupLogListResp),
|
|
Auth: true,
|
|
})
|
|
|
|
// 清理操作
|
|
Register(router, doc, basePath, "GET", "/data-cleanup/preview", handler.Preview, RouteSpec{
|
|
Summary: "预览待清理数据",
|
|
Tags: []string{"轮询管理-数据清理"},
|
|
Input: nil,
|
|
Output: new(dto.DataCleanupPreviewResp),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(router, doc, basePath, "GET", "/data-cleanup/progress", handler.GetProgress, RouteSpec{
|
|
Summary: "获取数据清理进度",
|
|
Tags: []string{"轮询管理-数据清理"},
|
|
Input: nil,
|
|
Output: new(dto.DataCleanupProgressResp),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(router, doc, basePath, "POST", "/data-cleanup/trigger", handler.TriggerCleanup, RouteSpec{
|
|
Summary: "手动触发数据清理",
|
|
Tags: []string{"轮询管理-数据清理"},
|
|
Input: new(dto.TriggerDataCleanupReq),
|
|
Output: nil,
|
|
Auth: true,
|
|
})
|
|
}
|