models

package
v0.0.0-...-991afdd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2025 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UserByDate

type UserByDate struct {
	TenantID    string `db:"tenant_id"`    // Multi-tenant isolation (partition key part 1)
	CreatedDate string `db:"created_date"` // Format: YYYY-MM-DD (partition key part 2)
	ID          string `db:"id"`           // Clustering column
	Email       string `db:"email"`
	FirstName   string `db:"first_name"`
	LastName    string `db:"last_name"`
	Name        string `db:"name"`
	LexicalName string `db:"lexical_name"`
	Timezone    string `db:"timezone"`
	Role        int    `db:"role"`
	Status      int    `db:"status"`

	// Profile data fields (flattened)
	Phone                                          string `db:"phone"`
	Country                                        string `db:"country"`
	Region                                         string `db:"region"`
	City                                           string `db:"city"`
	PostalCode                                     string `db:"postal_code"`
	AddressLine1                                   string `db:"address_line1"`
	AddressLine2                                   string `db:"address_line2"`
	HasShippingAddress                             bool   `db:"has_shipping_address"`
	ShippingName                                   string `db:"shipping_name"`
	ShippingPhone                                  string `db:"shipping_phone"`
	ShippingCountry                                string `db:"shipping_country"`
	ShippingRegion                                 string `db:"shipping_region"`
	ShippingCity                                   string `db:"shipping_city"`
	ShippingPostalCode                             string `db:"shipping_postal_code"`
	ShippingAddressLine1                           string `db:"shipping_address_line1"`
	ShippingAddressLine2                           string `db:"shipping_address_line2"`
	ProfileTimezone                                string `db:"profile_timezone"`
	AgreeTermsOfService                            bool   `db:"agree_terms_of_service"`
	AgreePromotions                                bool   `db:"agree_promotions"`
	AgreeToTrackingAcrossThirdPartyAppsAndServices bool   `db:"agree_to_tracking_across_third_party_apps_and_services"`

	// Security data fields (flattened)
	PasswordHashAlgorithm      string    `db:"password_hash_algorithm"`
	PasswordHash               string    `db:"password_hash"`
	WasEmailVerified           bool      `db:"was_email_verified"`
	Code                       string    `db:"code"`
	CodeType                   string    `db:"code_type"`
	CodeExpiry                 time.Time `db:"code_expiry"`
	OTPEnabled                 bool      `db:"otp_enabled"`
	OTPVerified                bool      `db:"otp_verified"`
	OTPValidated               bool      `db:"otp_validated"`
	OTPSecret                  string    `db:"otp_secret"`
	OTPAuthURL                 string    `db:"otp_auth_url"`
	OTPBackupCodeHash          string    `db:"otp_backup_code_hash"`
	OTPBackupCodeHashAlgorithm string    `db:"otp_backup_code_hash_algorithm"`

	// Metadata fields (flattened)
	// CWE-359: Encrypted IP addresses for GDPR compliance
	CreatedFromIPAddress    string    `db:"created_from_ip_address"`   // Encrypted with go-ipcrypt
	CreatedFromIPTimestamp  time.Time `db:"created_from_ip_timestamp"` // For 90-day expiration tracking
	CreatedByUserID         string    `db:"created_by_user_id"`
	CreatedByName           string    `db:"created_by_name"`
	ModifiedFromIPAddress   string    `db:"modified_from_ip_address"`   // Encrypted with go-ipcrypt
	ModifiedFromIPTimestamp time.Time `db:"modified_from_ip_timestamp"` // For 90-day expiration tracking
	ModifiedByUserID        string    `db:"modified_by_user_id"`
	ModifiedAt              time.Time `db:"modified_at"`
	ModifiedByName          string    `db:"modified_by_name"`
	LastLoginAt             time.Time `db:"last_login_at"`

	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

UserByDate represents the users_by_date table Query pattern: List users sorted by creation date Primary key: ((tenant_id, created_date), id) - composite partition key + clustering

func FromUserByDate

func FromUserByDate(tenantID string, u *user.User) *UserByDate

FromUserByDate converts domain entity to table model

func (*UserByDate) ToUser

func (u *UserByDate) ToUser() *user.User

ToUser converts table model to domain entity

type UserByEmail

type UserByEmail struct {
	TenantID    string `db:"tenant_id"` // Multi-tenant isolation
	Email       string `db:"email"`
	ID          string `db:"id"`
	FirstName   string `db:"first_name"`
	LastName    string `db:"last_name"`
	Name        string `db:"name"`
	LexicalName string `db:"lexical_name"`
	Timezone    string `db:"timezone"`
	Role        int    `db:"role"`
	Status      int    `db:"status"`

	// Profile data fields (flattened)
	Phone                                          string `db:"phone"`
	Country                                        string `db:"country"`
	Region                                         string `db:"region"`
	City                                           string `db:"city"`
	PostalCode                                     string `db:"postal_code"`
	AddressLine1                                   string `db:"address_line1"`
	AddressLine2                                   string `db:"address_line2"`
	HasShippingAddress                             bool   `db:"has_shipping_address"`
	ShippingName                                   string `db:"shipping_name"`
	ShippingPhone                                  string `db:"shipping_phone"`
	ShippingCountry                                string `db:"shipping_country"`
	ShippingRegion                                 string `db:"shipping_region"`
	ShippingCity                                   string `db:"shipping_city"`
	ShippingPostalCode                             string `db:"shipping_postal_code"`
	ShippingAddressLine1                           string `db:"shipping_address_line1"`
	ShippingAddressLine2                           string `db:"shipping_address_line2"`
	ProfileTimezone                                string `db:"profile_timezone"`
	AgreeTermsOfService                            bool   `db:"agree_terms_of_service"`
	AgreePromotions                                bool   `db:"agree_promotions"`
	AgreeToTrackingAcrossThirdPartyAppsAndServices bool   `db:"agree_to_tracking_across_third_party_apps_and_services"`

	// Security data fields (flattened)
	PasswordHashAlgorithm      string    `db:"password_hash_algorithm"`
	PasswordHash               string    `db:"password_hash"`
	WasEmailVerified           bool      `db:"was_email_verified"`
	Code                       string    `db:"code"`
	CodeType                   string    `db:"code_type"`
	CodeExpiry                 time.Time `db:"code_expiry"`
	OTPEnabled                 bool      `db:"otp_enabled"`
	OTPVerified                bool      `db:"otp_verified"`
	OTPValidated               bool      `db:"otp_validated"`
	OTPSecret                  string    `db:"otp_secret"`
	OTPAuthURL                 string    `db:"otp_auth_url"`
	OTPBackupCodeHash          string    `db:"otp_backup_code_hash"`
	OTPBackupCodeHashAlgorithm string    `db:"otp_backup_code_hash_algorithm"`

	// Metadata fields (flattened)
	// CWE-359: Encrypted IP addresses for GDPR compliance
	CreatedFromIPAddress    string    `db:"created_from_ip_address"`   // Encrypted with go-ipcrypt
	CreatedFromIPTimestamp  time.Time `db:"created_from_ip_timestamp"` // For 90-day expiration tracking
	CreatedByUserID         string    `db:"created_by_user_id"`
	CreatedByName           string    `db:"created_by_name"`
	ModifiedFromIPAddress   string    `db:"modified_from_ip_address"`   // Encrypted with go-ipcrypt
	ModifiedFromIPTimestamp time.Time `db:"modified_from_ip_timestamp"` // For 90-day expiration tracking
	ModifiedByUserID        string    `db:"modified_by_user_id"`
	ModifiedAt              time.Time `db:"modified_at"`
	ModifiedByName          string    `db:"modified_by_name"`
	LastLoginAt             time.Time `db:"last_login_at"`

	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

UserByEmail represents the users_by_email table Query pattern: Get user by email (for login, uniqueness checks) Primary key: (tenant_id, email) - composite partition key for multi-tenancy

func FromUserByEmail

func FromUserByEmail(tenantID string, u *user.User) *UserByEmail

FromUserByEmail converts domain entity to table model

func (*UserByEmail) ToUser

func (u *UserByEmail) ToUser() *user.User

ToUser converts table model to domain entity

type UserByID

type UserByID struct {
	TenantID    string `db:"tenant_id"` // Multi-tenant isolation
	ID          string `db:"id"`
	Email       string `db:"email"`
	FirstName   string `db:"first_name"`
	LastName    string `db:"last_name"`
	Name        string `db:"name"`
	LexicalName string `db:"lexical_name"`
	Timezone    string `db:"timezone"`
	Role        int    `db:"role"`
	Status      int    `db:"status"`

	// Profile data fields (flattened)
	Phone                                          string `db:"phone"`
	Country                                        string `db:"country"`
	Region                                         string `db:"region"`
	City                                           string `db:"city"`
	PostalCode                                     string `db:"postal_code"`
	AddressLine1                                   string `db:"address_line1"`
	AddressLine2                                   string `db:"address_line2"`
	HasShippingAddress                             bool   `db:"has_shipping_address"`
	ShippingName                                   string `db:"shipping_name"`
	ShippingPhone                                  string `db:"shipping_phone"`
	ShippingCountry                                string `db:"shipping_country"`
	ShippingRegion                                 string `db:"shipping_region"`
	ShippingCity                                   string `db:"shipping_city"`
	ShippingPostalCode                             string `db:"shipping_postal_code"`
	ShippingAddressLine1                           string `db:"shipping_address_line1"`
	ShippingAddressLine2                           string `db:"shipping_address_line2"`
	ProfileTimezone                                string `db:"profile_timezone"`
	AgreeTermsOfService                            bool   `db:"agree_terms_of_service"`
	AgreePromotions                                bool   `db:"agree_promotions"`
	AgreeToTrackingAcrossThirdPartyAppsAndServices bool   `db:"agree_to_tracking_across_third_party_apps_and_services"`

	// Security data fields (flattened)
	PasswordHashAlgorithm      string    `db:"password_hash_algorithm"`
	PasswordHash               string    `db:"password_hash"`
	WasEmailVerified           bool      `db:"was_email_verified"`
	Code                       string    `db:"code"`
	CodeType                   string    `db:"code_type"`
	CodeExpiry                 time.Time `db:"code_expiry"`
	OTPEnabled                 bool      `db:"otp_enabled"`
	OTPVerified                bool      `db:"otp_verified"`
	OTPValidated               bool      `db:"otp_validated"`
	OTPSecret                  string    `db:"otp_secret"`
	OTPAuthURL                 string    `db:"otp_auth_url"`
	OTPBackupCodeHash          string    `db:"otp_backup_code_hash"`
	OTPBackupCodeHashAlgorithm string    `db:"otp_backup_code_hash_algorithm"`

	// Metadata fields (flattened)
	// CWE-359: Encrypted IP addresses for GDPR compliance
	CreatedFromIPAddress    string    `db:"created_from_ip_address"`   // Encrypted with go-ipcrypt
	CreatedFromIPTimestamp  time.Time `db:"created_from_ip_timestamp"` // For 90-day expiration tracking
	CreatedByUserID         string    `db:"created_by_user_id"`
	CreatedByName           string    `db:"created_by_name"`
	ModifiedFromIPAddress   string    `db:"modified_from_ip_address"`   // Encrypted with go-ipcrypt
	ModifiedFromIPTimestamp time.Time `db:"modified_from_ip_timestamp"` // For 90-day expiration tracking
	ModifiedByUserID        string    `db:"modified_by_user_id"`
	ModifiedAt              time.Time `db:"modified_at"`
	ModifiedByName          string    `db:"modified_by_name"`
	LastLoginAt             time.Time `db:"last_login_at"`

	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

UserByID represents the users_by_id table Query pattern: Get user by ID Primary key: (tenant_id, id) - composite partition key for multi-tenancy

func FromUser

func FromUser(tenantID string, u *user.User) *UserByID

FromUser converts domain entity to table model

func (*UserByID) ToUser

func (u *UserByID) ToUser() *user.User

ToUser converts table model to domain entity

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL