mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-03 18:22:57 +00:00
27 lines
1.0 KiB
Go
27 lines
1.0 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// AuditLog represents an audit trail entry
|
|
type AuditLog struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
UserID *uint `json:"user_id"`
|
|
User *User `gorm:"foreignKey:UserID" json:"user,omitempty"`
|
|
Action string `gorm:"type:varchar(100);not null" json:"action"` // CREATE, UPDATE, DELETE, LOGIN, etc.
|
|
EntityType string `gorm:"type:varchar(100)" json:"entity_type"` // Article, User, Settings, etc.
|
|
EntityID *uint `json:"entity_id"`
|
|
Description string `gorm:"type:text" json:"description"`
|
|
IPAddress string `gorm:"type:varchar(45)" json:"ip_address"`
|
|
UserAgent string `gorm:"type:text" json:"user_agent"`
|
|
Changes string `gorm:"type:json" json:"changes,omitempty"` // JSON string of before/after values
|
|
Metadata string `gorm:"type:json" json:"metadata,omitempty"` // Additional context as JSON
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// TableName overrides the default table name
|
|
func (AuditLog) TableName() string {
|
|
return "audit_logs"
|
|
}
|