package model 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 "audit_operation_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"` }