user

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IRedisRepository

type IRedisRepository interface {
	// Get returns the value of the given key.
	Get(ctx context.Context, id uint) (string, error)
	// Set sets the value of the given key.
	Set(ctx context.Context, id uint, value string) error
}

IRedisRepository is the user redis repository interface.

func NewRedisRepository

func NewRedisRepository(redisConn *redis.Client) IRedisRepository

NewRedisRepository returns a new redis repository.

type IRepository

type IRepository interface {
	// GetName returns the name of the user.
	GetName(ctx context.Context, id uint) string
	// GetByID returns the user with the given id.
	GetByID(ctx context.Context, id uint) (domain.User, error)
	// GetByEmail returns the user with the given email.
	GetByEmail(ctx context.Context, email string) (domain.User, error)
	// Create creates a new user.
	Create(ctx context.Context, user *domain.User) error
	// Update updates the user with the given id.
	Update(ctx context.Context, user *domain.User) error
	// Delete deletes the user with the given id.
	Delete(ctx context.Context, id uint) error
	// GetByOauthID returns the user with the given oauth id.
	GetByOauthID(ctx context.Context, id string) (domain.User, error)
}

IRepository is the user repository interface.

func NewRepository

func NewRepository(dbConn *gorm.DB) IRepository

NewRepository returns a new repository.

type IRistrettoRepository

type IRistrettoRepository interface {
	// Get returns the value of the given key
	Get(ctx context.Context, id uint) (domain.User, error)
	// Set sets the value of the given key
	Set(ctx context.Context, user domain.User) error
	// Delete deletes the value of the given key
	Delete(ctx context.Context, id uint) error
}

func NewRistrettoCache

func NewRistrettoCache(ristrettoCache *ristretto.Cache) IRistrettoRepository

type IUseCase

type IUseCase interface {
	// GetName returns the name of the user.
	GetName(ctx context.Context, id string) string
	// GetByID returns the user with the given id.
	GetByID(ctx context.Context, id uint) (domain.User, error)
}

IUseCase is the user use case interface.

func NewUseCase

func NewUseCase(repo IRepository, redis IRedisRepository, ristretto IRistrettoRepository) IUseCase

NewUseCase returns a new user use case.

type RedisRepository

type RedisRepository struct {
	RedisConn *redis.Client // RedisConn is the redis connection.
}

RedisRepository is the interface for the redis repository.

func (*RedisRepository) Get

func (r *RedisRepository) Get(ctx context.Context, id uint) (string, error)

Get gets the user by id.

func (*RedisRepository) Set

func (r *RedisRepository) Set(ctx context.Context, id uint, value string) error

Set sets the user by id.

type RistrettoRepository

type RistrettoRepository struct {
	RistrettoCache *ristretto.Cache // RistrettoCache is the cache
}

func (*RistrettoRepository) Delete

func (r *RistrettoRepository) Delete(ctx context.Context, id uint) error

func (*RistrettoRepository) Get

func (*RistrettoRepository) Set

func (r *RistrettoRepository) Set(ctx context.Context, user domain.User) error

type SQLRepository

type SQLRepository struct {
	DBConn *gorm.DB // DBConn is the database connection.
}

SQLRepository is the repository for the user.

func (*SQLRepository) Create

func (r *SQLRepository) Create(ctx context.Context, user *domain.User) error

Create creates a new user.

func (*SQLRepository) Delete

func (r *SQLRepository) Delete(ctx context.Context, id uint) error

Delete deletes the user with the given id.

func (*SQLRepository) GetByEmail

func (r *SQLRepository) GetByEmail(ctx context.Context, email string) (domain.User, error)

GetByEmail returns the user with the given email.

func (*SQLRepository) GetByID

func (r *SQLRepository) GetByID(ctx context.Context, id uint) (domain.User, error)

GetByID returns the user with the given id.

func (*SQLRepository) GetByOauthID

func (r *SQLRepository) GetByOauthID(ctx context.Context, id string) (domain.User, error)

GetByOauthID returns the user with the given oauth id.

func (*SQLRepository) GetName

func (r *SQLRepository) GetName(ctx context.Context, id uint) string

GetName returns the name of the user.

func (*SQLRepository) Update

func (r *SQLRepository) Update(ctx context.Context, user *domain.User) error

Update updates the user with the given id.

type UseCase

UseCase is the user use case.

func (UseCase) GetByID

func (u UseCase) GetByID(ctx context.Context, id uint) (domain.User, error)

GetByID returns the user with the given id.

func (UseCase) GetName

func (u UseCase) GetName(ctx context.Context, id string) string

GetName returns the name of the user with the given id.

Jump to

Keyboard shortcuts

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