Files
aiops/backend/model/common.go
T
attacker 77c234b060 feat(audit): F1+F2 告警静默规则标记完成 + 审计日志CSV导出实现
F1 告警静默规则 [done]:
- 后端 alert_silence.go: CRUD + Toggle (onetime/daily/weekly 三模式)
- 告警引擎 isSilenced 集成 (alert_engine.go)
- 前端 SilenceRuleTab + SilenceDialog
- 路由 /alerts/silences 已注册

F2 审计日志导出 [done]:
- 重写 ExportAuditLogs: 真正的 CSV 导出 (encoding/csv + UTF-8 BOM)
- 支持 module/action/username/startTime/endTime 筛选
- 导出限制 10000 条防溢出,自动记录审计日志
- JSON 格式向后兼容 (format=json)
- 前端 exportLogs 传递查询参数

同时包含累积的前期工作:
- 目录重构 internal/ -> controller/model/router (v0.55-v0.57)
- 后端分层架构 dto/repository/service/utils
- 审计模块全功能 (终端审计/操作审计/登录日志)
- asciicast v2 录制格式
- SFTP 文件浏览器
- StatStrip 紧凑统计条
- 在线会话自动刷新
- LiveMonitor WebSocket 诊断修复

验证: go build ✅ | npm run build ✅ | Docker 部署 ✅ | 10 回归端点 ✅ | CSV 导出 ✅ | 静默 CRUD ✅
2026-06-25 20:16:30 +08:00

112 lines
2.7 KiB
Go

package model
// Response 通用响应
type Response struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
// ListResponse 列表响应
type ListResponse struct {
List interface{} `json:"list"`
Total int64 `json:"total"`
}
// PageQuery 分页查询
type PageQuery struct {
Page int `form:"page,default=1"`
PageSize int `form:"page_size,default=20"`
Keyword string `form:"keyword"`
Sort string `form:"sort"`
Order string `form:"order,default=desc"`
}
// GetOffset 获取偏移量
func (p *PageQuery) GetOffset() int {
if p.Page < 1 {
p.Page = 1
}
return (p.Page - 1) * p.GetLimit()
}
// GetLimit 获取每页数量
func (p *PageQuery) GetLimit() int {
if p.PageSize < 1 {
p.PageSize = 20
}
if p.PageSize > 100 {
p.PageSize = 100
}
return p.PageSize
}
// IDRequest ID请求
type IDRequest struct {
ID uint `uri:"id" binding:"required"`
}
// IDsRequest IDs请求
type IDsRequest struct {
IDs []uint `json:"ids" binding:"required"`
}
// StatusRequest 状态请求
type StatusRequest struct {
Status int `json:"status" binding:"required,oneof=0 1"`
}
// DashboardStats 仪表盘统计
type DashboardStats struct {
ServerStats ServerStats `json:"server_stats"`
K8sStats KubernetesClusterStats `json:"kubernetes_stats"`
AlertStats AlertStats `json:"alert_stats"`
PipelineStats PipelineStats `json:"pipeline_stats"`
CostStats CostStats `json:"cost_stats"`
TopResourceUsage TopResourceUsage `json:"top_resource_usage"`
ExpiringCerts []DomainCert `json:"expiring_certs"`
}
// CostStats 成本统计
type CostStats struct {
TotalCost float64 `json:"total_cost"`
MonthCost float64 `json:"month_cost"`
CloudCosts []CloudCost `json:"cloud_costs"`
MonthTrend []MonthTrend `json:"month_trend"`
}
// CloudCost 云平台成本
type CloudCost struct {
Cloud string `json:"cloud"`
Cost float64 `json:"cost"`
}
// MonthTrend 月度趋势
type MonthTrend struct {
Month string `json:"month"`
Cost float64 `json:"cost"`
}
// TopResourceUsage Top资源使用
type TopResourceUsage struct {
CPU []ServerResource `json:"cpu"`
Memory []ServerResource `json:"memory"`
Disk []ServerResource `json:"disk"`
}
// ServerResource 服务器资源
type ServerResource struct {
ID uint `json:"id"`
Hostname string `json:"hostname"`
IP string `json:"ip"`
Usage float64 `json:"usage"`
}
// DomainCert 域名证书
type DomainCert struct {
ID uint `json:"id"`
Name string `json:"name"`
ExpireDate string `json:"expire_date"`
DaysUntilExpiry int `json:"days_until_expiry"`
}