Documentation ¶
Index ¶
- type IRedisRepository
- type IRepository
- type IRistrettoRepository
- type IUseCase
- type RedisRepository
- type RistrettoRepository
- type SQLRepository
- func (r *SQLRepository) Create(ctx context.Context, user *domain.User) error
- func (r *SQLRepository) Delete(ctx context.Context, id uint) error
- func (r *SQLRepository) GetByEmail(ctx context.Context, email string) (domain.User, error)
- func (r *SQLRepository) GetByID(ctx context.Context, id uint) (domain.User, error)
- func (r *SQLRepository) GetByOauthID(ctx context.Context, id string) (domain.User, error)
- func (r *SQLRepository) GetName(ctx context.Context, id uint) string
- func (r *SQLRepository) Update(ctx context.Context, user *domain.User) error
- type UseCase
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.
type RistrettoRepository ¶
func (*RistrettoRepository) Delete ¶
func (r *RistrettoRepository) Delete(ctx context.Context, id uint) error
type SQLRepository ¶
SQLRepository is the repository for the 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 ¶
GetByEmail returns the user with the given email.
func (*SQLRepository) GetByOauthID ¶
GetByOauthID returns the user with the given oauth id.
type UseCase ¶
type UseCase struct { IRepository IRedisRepository IRistrettoRepository }
UseCase is the user use case.
Click to show internal directories.
Click to hide internal directories.