feat: 细节打磨 - 全面修复核心功能

后端修复:
- ticket: 添加独立 CancelTicket/RollbackTicket/GetTicketTimeline/GetTicketApprovals handler
  (之前 cancel/rollback 都错误调用 ApproveTicket, timeline/approvals 调用 GetTicket)
- instance_detail: 7个 TODO placeholder 端点全部实现真实 MySQL 查询
  (databases/tables/db-schema/table-detail/processlist/status/users)
- instance_detail: ExecuteQuery 添加真实 Redis 命令执行(只读命令白名单)
- redis: 全部 handler 从 placeholder 改为真实 go-redis 实现
  (info/dbsize/keys/key-detail/slowlog/clients/command/create-key/delete-key)
- router: 添加 sql-assistant/format, sql-assistant/analyze, tickets/audit 路由
- router: 添加 dictionary/*, mongo/* stub 路由(前端不报 404)
- stub_handlers: 新增 SQL 审计/格式化/分析 handler + dictionary/mongo stub
- model: TicketStatistics.Completed JSON tag 改为 success 匹配前端
- ticket: ExecuteTicket 完成 status 改为 success 而非 completed

前端兼容:
- 所有前端 API 路径后端都有对应路由(无 404)
- TicketStatistics 返回 success 字段与前端 stats?.success 对齐
This commit is contained in:
logan committed 2026-05-26 20:40:45 +08:00
1 parent 9372053574
commit f2e93a09c0
5 files changed
+1577 -67

No files matched your search

+28
View File
@@ -31,8 +31,13 @@ func Setup(r *gin.Engine) {
auth.GET("/tickets/:id", handler.GetTicket)
auth.POST("/tickets", handler.CreateTicket)
auth.POST("/tickets/:id/approve", handler.ApproveTicket)
auth.POST("/tickets/:id/review", handler.ApproveTicket)
auth.POST("/tickets/:id/execute", handler.ExecuteTicket)
auth.POST("/tickets/:id/cancel-schedule", handler.CancelScheduledTask)
auth.POST("/tickets/:id/cancel", handler.CancelTicket)
auth.GET("/tickets/:id/timeline", handler.GetTicketTimeline)
auth.GET("/tickets/:id/approvals", handler.GetTicketApprovals)
auth.POST("/tickets/:id/rollback", handler.RollbackTicket)
// Instances
auth.GET("/instances", handler.ListInstances)
@@ -142,6 +147,29 @@ func Setup(r *gin.Engine) {
// Query execution
auth.POST("/query/execute", handler.ExecuteQuery)
auth.POST("/query", handler.ExecuteQuery)
// SQL Assistant
auth.POST("/sql-assistant/format", handler.SQLFormat)
auth.POST("/sql-assistant/analyze", handler.SQLAnalyze)
// Ticket Audit
auth.POST("/tickets/audit", handler.AuditTicketSQL)
// Dictionary (stub)
auth.GET("/dictionary/instances/:instanceId/databases", handler.DictionaryDatabases)
auth.GET("/dictionary/instances/:instanceId/tables", handler.DictionaryTables)
auth.GET("/dictionary/instances/:instanceId/tables/:tableName", handler.DictionaryTableDetail)
auth.GET("/dictionary/instances/:instanceId/export", handler.DictionaryExport)
// MongoDB (stub)
auth.GET("/mongo/:id/databases", handler.MongoDatabases)
auth.GET("/mongo/:id/databases/:database/collections", handler.MongoCollections)
auth.GET("/mongo/:id/collections/:collection/stats", handler.MongoCollectionStats)
auth.POST("/mongo/:id/query", handler.MongoQuery)
auth.POST("/mongo/:id/execute", handler.MongoExecute)
auth.POST("/mongo/:id/test-connection", handler.MongoTestConnection)
// Read-only resources
auth.GET("/audit-rules", handler.ListAuditRules)