package domain import ( "context" "time" ) // ActivityAction represents the type of action performed type ActivityAction string const ( ActivityActionCreate ActivityAction = "create" ActivityActionUpdate ActivityAction = "update" ActivityActionDelete ActivityAction = "delete" ActivityActionVerify ActivityAction = "verify" ActivityActionReject ActivityAction = "reject" ActivityActionLogin ActivityAction = "login" ActivityActionLogout ActivityAction = "logout" ActivityActionView ActivityAction = "view" ActivityActionExport ActivityAction = "export" ActivityActionImport ActivityAction = "import" ActivityActionOther ActivityAction = "other" ) // ActivityLog represents a system activity log entry type ActivityLog struct { ID string `gorm:"primaryKey;type:text"` UserID string `gorm:"type:text;not null;index"` Action ActivityAction `gorm:"type:varchar(50);not null;index"` TargetType string `gorm:"type:varchar(50);not null;index"` // organization, user, page, etc. TargetID string `gorm:"type:text;not null;index"` Metadata string `gorm:"type:jsonb"` // JSON object with additional data IPAddress string `gorm:"type:varchar(45)"` // IPv4 or IPv6 UserAgent string `gorm:"type:text"` Timestamp time.Time `gorm:"not null;index"` // Associations User *User `gorm:"foreignKey:UserID"` } // TableName specifies the table name for GORM func (ActivityLog) TableName() string { return "activity_logs" } // ActivityLogRepository defines the interface for activity log operations type ActivityLogRepository interface { Create(ctx context.Context, activity *ActivityLog) error GetByUser(ctx context.Context, userID string, limit, offset int) ([]*ActivityLog, int64, error) GetByTarget(ctx context.Context, targetType, targetID string, limit, offset int) ([]*ActivityLog, int64, error) GetRecent(ctx context.Context, limit int) ([]*ActivityLog, error) GetByAction(ctx context.Context, action ActivityAction, limit, offset int) ([]*ActivityLog, int64, error) }