package models import ( "context" "time" ) // OTP represents a TOTP configuration type OTP struct { ID int64 `json:"id" db:"id"` UserID string `json:"user_id" db:"user_id" validate:"required"` OpenID string `json:"openid" db:"openid" validate:"required"` Name string `json:"name" db:"name" validate:"required,min=1,max=100,no_xss"` Issuer string `json:"issuer" db:"issuer" validate:"omitempty,issuer"` Secret string `json:"secret" db:"secret" validate:"required,otpsecret"` Algorithm string `json:"algorithm" db:"algorithm" validate:"required,oneof=SHA1 SHA256 SHA512"` Digits int `json:"digits" db:"digits" validate:"required,min=6,max=8"` Period int `json:"period" db:"period" validate:"required,min=30,max=60"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` } // OTPParams represents common OTP parameters used in creation and update type OTPParams struct { Name string `json:"name" validate:"required,min=1,max=100,no_xss"` Issuer string `json:"issuer" validate:"omitempty,issuer"` Secret string `json:"secret" validate:"required,otpsecret"` Algorithm string `json:"algorithm" validate:"omitempty,oneof=SHA1 SHA256 SHA512"` Digits int `json:"digits" validate:"omitempty,min=6,max=8"` Period int `json:"period" validate:"omitempty,min=30,max=60"` } // OTPRepository handles OTP data storage type OTPRepository struct { // Add your database connection or ORM here } // Create creates a new OTP record func (r *OTPRepository) Create(ctx context.Context, otp *OTP) error { // Implement database creation logic return nil } // FindByID finds an OTP by ID and user ID func (r *OTPRepository) FindByID(ctx context.Context, id, userID string) (*OTP, error) { // Implement database lookup logic return nil, nil } // FindAllByUserID finds all OTPs for a user func (r *OTPRepository) FindAllByUserID(ctx context.Context, userID string) ([]*OTP, error) { // Implement database query logic return nil, nil } // Update updates an existing OTP record func (r *OTPRepository) Update(ctx context.Context, otp *OTP) error { // Implement database update logic return nil } // Delete deletes an OTP record func (r *OTPRepository) Delete(ctx context.Context, id, userID string) error { // Implement database deletion logic return nil }