25 lines
1.1 KiB
Go
25 lines
1.1 KiB
Go
package entity
|
|
|
|
import (
|
|
"time"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type ActivityLog struct {
|
|
ID uuid.UUID `json:"id" gorm:"type:uuid;primaryKey"`
|
|
UserID uuid.UUID `json:"user_id" gorm:"type:uuid;not null"`
|
|
User User `json:"user" gorm:"foreignKey:UserID"`
|
|
Action string `json:"action" gorm:"not null"` // CREATE, UPDATE, DELETE, LOGIN, LOGOUT
|
|
Resource string `json:"resource" gorm:"not null"` // devices, backbone, fishbone, towers, etc.
|
|
ResourceID *string `json:"resource_id,omitempty"` // ID of the affected resource
|
|
OldData *string `json:"old_data,omitempty" gorm:"type:text"` // JSON of old data for updates
|
|
NewData *string `json:"new_data,omitempty" gorm:"type:text"` // JSON of new data
|
|
IPAddress string `json:"ip_address"`
|
|
UserAgent string `json:"user_agent"`
|
|
Timestamp time.Time `json:"timestamp" gorm:"autoCreateTime"`
|
|
Details *string `json:"details,omitempty"` // Additional details
|
|
}
|
|
|
|
func (ActivityLog) TableName() string {
|
|
return "activity_logs"
|
|
} |