repositories

package
v0.0.0-...-be4b6df Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoDBConn                         = errors.New("no database connection")
	ErrLoginIsAlreadyTaken              = errors.New("login is already taken")
	ErrInvalidLoginPasswordPair         = errors.New("invalid login/password pair")
	ErrOrderNumberUploadedThisClient    = errors.New("order number has been uploaded by this client")
	ErrOrderNumberUploadedAnotherClient = errors.New("order number has been uploaded by another client")
	ErrThereAreNotEnoughAccrual         = errors.New("there are not enough accrual")
)

Functions

This section is empty.

Types

type Repo

type Repo interface {
	SaveClient(context.Context, models.Client) (id int, err error)
	FindClient(context.Context, models.Client) (id int, err error)

	SaveOrder(context.Context, *models.Order) (err error)
	FindOrders(context.Context, models.Client) (orders []models.Order, err error)

	SaveWithdrawal(context.Context, *models.Withdrawal) (err error)
	FindWithdrawals(context.Context, models.Client) (withdrawals []models.Withdrawal, err error)

	FindBalance(context.Context, models.Client) (balance *models.Balace, err error)

	SaveTask(context.Context, models.Task) (err error)
	FindTasks(context.Context, ...string) (tasks []models.Task, err error)

	Ping(context.Context) error
	Close() error
}

type RepoPostgreSQL

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

func NewRepositoryPostgreSQL

func NewRepositoryPostgreSQL(dsn string) (repo RepoPostgreSQL, err error)

func (RepoPostgreSQL) Close

func (repo RepoPostgreSQL) Close() error

func (RepoPostgreSQL) FindBalance

func (repo RepoPostgreSQL) FindBalance(ctx context.Context, client models.Client) (balance *models.Balace, err error)

func (RepoPostgreSQL) FindClient

func (repo RepoPostgreSQL) FindClient(ctx context.Context, client models.Client) (clientID int, err error)

func (RepoPostgreSQL) FindOrders

func (repo RepoPostgreSQL) FindOrders(ctx context.Context, client models.Client) (orders []models.Order, err error)

func (RepoPostgreSQL) FindTasks

func (repo RepoPostgreSQL) FindTasks(ctx context.Context, statuses ...string) (tasks []models.Task, err error)

func (RepoPostgreSQL) FindWithdrawals

func (repo RepoPostgreSQL) FindWithdrawals(ctx context.Context, client models.Client) (withdrawals []models.Withdrawal, err error)

func (RepoPostgreSQL) Ping

func (repo RepoPostgreSQL) Ping(ctx context.Context) error

func (RepoPostgreSQL) SaveClient

func (repo RepoPostgreSQL) SaveClient(ctx context.Context, client models.Client) (clientID int, err error)

func (RepoPostgreSQL) SaveOrder

func (repo RepoPostgreSQL) SaveOrder(ctx context.Context, order *models.Order) (err error)

func (RepoPostgreSQL) SaveTask

func (repo RepoPostgreSQL) SaveTask(ctx context.Context, task models.Task) (err error)

func (RepoPostgreSQL) SaveWithdrawal

func (repo RepoPostgreSQL) SaveWithdrawal(ctx context.Context, withdrawal *models.Withdrawal) (err error)

Jump to

Keyboard shortcuts

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