mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 18:52:56 +00:00
dev day #65
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
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"
|
||||
}
|
||||
Reference in New Issue
Block a user