repository

package
v0.0.0-...-88a34c4 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPostgresDB

func NewPostgresDB(cfg PostgresConfig) (*sqlx.DB, error)

NewPostgresDB ...

func NewRedisCache

func NewRedisCache(cfg RedisConfig) *redis.Client

Types

type AuthPostgres

type AuthPostgres struct {
	// contains filtered or unexported fields
}

func NewAuthPostgres

func NewAuthPostgres(db *sqlx.DB, cache *redis.Client) *AuthPostgres

func (*AuthPostgres) CreateUser

func (r *AuthPostgres) CreateUser(user models.User) (int, error)

func (*AuthPostgres) GetRefreshToken

func (r *AuthPostgres) GetRefreshToken(userId int) (string, error)

func (*AuthPostgres) GetUserByUsername

func (r *AuthPostgres) GetUserByUsername(username string) (models.User, error)

func (*AuthPostgres) SaveRefreshToken

func (r *AuthPostgres) SaveRefreshToken(userId int, token string) error

type Authorization

type Authorization interface {
	CreateUser(user models.User) (int, error)
	GetUserByUsername(username string) (models.User, error)
	SaveRefreshToken(userId int, token string) error
	GetRefreshToken(userId int) (string, error)
}

type PostgresConfig

type PostgresConfig struct {
	Host     string
	Port     string
	Username string
	Password string
	DBName   string
	SSLMode  string
}

PostgresConfig for postgres db connection

type RedisConfig

type RedisConfig struct {
	Address  string
	Password string
	DB       int
}

type Repository

type Repository struct {
	Authorization
	TodoList
	TodoItem
}

func NewRepository

func NewRepository(db *sqlx.DB, cache *redis.Client) *Repository

NewRepository returns new repository

type TodoItem

type TodoItem interface {
	Create(listId int, item models.TodoItem) (int, error)
	GetAll(userId, listId int) ([]models.TodoItem, error)
	GetById(userId, itemId int) (models.TodoItem, error)
	Delete(userId, itemId int) error
	Update(userId, itemId int, input dto.UpdateItem) error
}

type TodoItemPostgres

type TodoItemPostgres struct {
	// contains filtered or unexported fields
}

func NewTodoItemPostgres

func NewTodoItemPostgres(db *sqlx.DB) *TodoItemPostgres

func (*TodoItemPostgres) Create

func (r *TodoItemPostgres) Create(listId int, item models.TodoItem) (int, error)

func (*TodoItemPostgres) Delete

func (r *TodoItemPostgres) Delete(userId, itemId int) error

func (*TodoItemPostgres) GetAll

func (r *TodoItemPostgres) GetAll(userId, listId int) ([]models.TodoItem, error)

func (*TodoItemPostgres) GetById

func (r *TodoItemPostgres) GetById(userId, itemId int) (models.TodoItem, error)

func (*TodoItemPostgres) Update

func (r *TodoItemPostgres) Update(userId, itemId int, input dto.UpdateItem) error

type TodoList

type TodoList interface {
	Create(userId int, list models.TodoList) (int, error)
	GetAll(userId int) ([]models.TodoList, error)
	GetById(userId, listId int) (models.TodoList, error)
	Delete(userId, listId int) error
	Update(userId, listId int, input dto.UpdateList) error
}

type TodoListPostgres

type TodoListPostgres struct {
	// contains filtered or unexported fields
}

func NewTodoListPostgres

func NewTodoListPostgres(db *sqlx.DB) *TodoListPostgres

func (*TodoListPostgres) Create

func (r *TodoListPostgres) Create(userId int, list models.TodoList) (int, error)

func (*TodoListPostgres) Delete

func (r *TodoListPostgres) Delete(userId, listId int) error

func (*TodoListPostgres) GetAll

func (r *TodoListPostgres) GetAll(userId int) ([]models.TodoList, error)

func (*TodoListPostgres) GetById

func (r *TodoListPostgres) GetById(userId, listId int) (models.TodoList, error)

func (*TodoListPostgres) Update

func (r *TodoListPostgres) Update(userId, listId int, input dto.UpdateList) error

Jump to

Keyboard shortcuts

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