- Agent: system.go 添加 readUptime(), SystemStat 携带 Uptime - Backend: Server 模型新增 Kernel 字段, ReceiveReport 持久化 kernel+uptime - Backend: /agent/latest 返回 kernel/uptime/port_info/disk_io_info/disk_total - Frontend: 磁盘监控改为 BPS+IOPS (4张卡片), 系统信息修复内核/运行时长/监听端口/磁盘容量 - 图表单位从 MB/s 改为 KB/s, 添加 formatBPS 工具函数
69 lines
2.0 KiB
Go
69 lines
2.0 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// AuditLog 审计日志模型
|
|
type AuditLog struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
UserID *uint `json:"user_id"`
|
|
Username string `gorm:"size:64" json:"username"`
|
|
IP string `gorm:"size:64" json:"ip"`
|
|
UserAgent string `gorm:"size:500" json:"user_agent"`
|
|
Module string `gorm:"size:64" json:"module"`
|
|
Action string `gorm:"size:64" json:"action"`
|
|
Resource string `gorm:"size:128" json:"resource"`
|
|
ResourceID string `gorm:"size:64" json:"resource_id"`
|
|
Request string `gorm:"type:text" json:"request"`
|
|
Response string `gorm:"type:text" json:"response"`
|
|
Status int `json:"status"`
|
|
Duration int `json:"duration"` // ms
|
|
Error string `gorm:"type:text" json:"error"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// TableName 表名
|
|
func (AuditLog) TableName() string {
|
|
return "sys_audit_logs"
|
|
}
|
|
|
|
// AuditLogQuery 审计日志查询
|
|
type AuditLogQuery struct {
|
|
UserID *uint `form:"user_id"`
|
|
Username string `form:"username"`
|
|
Module string `form:"module"`
|
|
Action string `form:"action"`
|
|
StartTime string `form:"start_time"`
|
|
EndTime string `form:"end_time"`
|
|
Page int `form:"page,default=1"`
|
|
PageSize int `form:"page_size,default=20"`
|
|
}
|
|
|
|
// AuditLogListResponse 审计日志列表响应
|
|
type AuditLogListResponse struct {
|
|
List []AuditLog `json:"list"`
|
|
Total int64 `json:"total"`
|
|
}
|
|
|
|
// AuditStats 审计统计
|
|
type AuditStats struct {
|
|
TodayCount int64 `json:"today_count"`
|
|
WeekCount int64 `json:"week_count"`
|
|
MonthCount int64 `json:"month_count"`
|
|
TopModules []ModuleStat `json:"top_modules"`
|
|
TopUsers []UserStat `json:"top_users"`
|
|
}
|
|
|
|
// ModuleStat 模块统计
|
|
type ModuleStat struct {
|
|
Module string `json:"module"`
|
|
Count int64 `json:"count"`
|
|
}
|
|
|
|
// UserStat 用户统计
|
|
type UserStat struct {
|
|
Username string `json:"username"`
|
|
Count int64 `json:"count"`
|
|
}
|