Documentation ¶
Overview ¶
Package service contains the business logic for wallets application.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrDatabase = httperr.New(http.StatusInternalServerError, "database error") ErrEmptyWalletFrom = httperr.New(http.StatusBadRequest, "empty wallet_from") ErrEmptyWalletName = httperr.New(http.StatusBadRequest, "empty wallet name") ErrEmptyWalletTo = httperr.New(http.StatusBadRequest, "empty wallet_to") ErrSameWallets = httperr.New(http.StatusBadRequest, "same wallets") ErrNegativeEndDate = httperr.New(http.StatusBadRequest, "end_date can't be negative") ErrNegativeOffset = httperr.New(http.StatusBadRequest, "offset can't be negative") ErrNegativeStartDate = httperr.New(http.StatusBadRequest, "start_date can't be negative") ErrNotPositiveAmount = httperr.New(http.StatusBadRequest, "amount must be positive") ErrNotPositiveLimit = httperr.New(http.StatusBadRequest, "limit must be positive") ErrUnsupportedOperationType = httperr.New(http.StatusBadRequest, "unsupported operation type") ErrWalletNotFound = httperr.New(http.StatusBadRequest, "wallet not found") )
Functions ¶
This section is empty.
Types ¶
type Repository ¶
type Repository interface { CreateWallet(walletName string) error GetWallet(walletName string) (*dto.Wallet, error) IncreaseWalletBalance(walletName string, amount uint64) error GetOperations(dto.OperationsFilter) ([]dto.Operation, error) RunWithTransaction(func(tx *sqlx.Tx) error) error GetWalletsForUpdateTx(tx *sqlx.Tx, walletNames []string) ([]dto.Wallet, error) TransferTx(tx *sqlx.Tx, walletFrom, walletTo string, amount uint64) error }
Repository describes the repository methods required for the service.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements the business logic for wallets application.
func NewService ¶
func NewService(logger *zap.SugaredLogger, repo Repository) *Service
NewService creates a service instance.
func (*Service) CreateWallet ¶
func (s *Service) CreateWallet(wallet dto.CreateWalletRequest) error
CreateWallet creates new wallet.
func (*Service) GetOperations ¶
GetOperations provides operations for the specified wallet according to filtering parameters.
func (*Service) IncreaseWalletBalance ¶
IncreaseWalletBalance increases wallet balance.
Click to show internal directories.
Click to hide internal directories.