2023-12-29 11:30:20 +00:00
|
|
|
package repository
|
|
|
|
|
|
|
|
import (
|
|
|
|
"codeword/internal/models"
|
2023-12-29 12:41:26 +00:00
|
|
|
"context"
|
|
|
|
"go.mongodb.org/mongo-driver/mongo"
|
|
|
|
"go.mongodb.org/mongo-driver/mongo/readpref"
|
2023-12-29 11:30:20 +00:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type UserRepository struct {
|
2023-12-29 12:41:26 +00:00
|
|
|
db *mongo.Database
|
2023-12-29 11:30:20 +00:00
|
|
|
}
|
|
|
|
|
2023-12-29 18:02:50 +00:00
|
|
|
//todo реализовать
|
|
|
|
|
2023-12-29 12:41:26 +00:00
|
|
|
func NewUserRepository(db *mongo.Database) *UserRepository {
|
|
|
|
return &UserRepository{db}
|
2023-12-29 11:30:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *UserRepository) FindByEmail(email string) (*models.User, error) {
|
|
|
|
//todo
|
|
|
|
return &models.User{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *UserRepository) StoreRecoveryRecord(userID, signature string, createdAt time.Time) error {
|
|
|
|
//todo
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *UserRepository) GetRecoveryRecord(signature string) (*models.RestoreRequest, error) {
|
|
|
|
return &models.RestoreRequest{UserID: "123", Sign: signature, CreatedAt: time.Now()}, nil
|
|
|
|
}
|
|
|
|
|
2023-12-29 12:41:26 +00:00
|
|
|
func (r *UserRepository) Ping(ctx context.Context) error {
|
|
|
|
return r.db.Client().Ping(ctx, readpref.Primary())
|
2023-12-29 11:30:20 +00:00
|
|
|
}
|