transaction

package
v0.0.0-...-514f96b Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCreate          = errors.New("create transaction")
	ErrAlreadyExist    = errors.New("transaction with given id already exist")
	ErrAccountNotFound = errors.New("account with given account_id not found")
)
View Source
var (
	Enrollment        = Type{"enrollment"}
	Transfer          = Type{"transfer"}
	Reservation       = Type{"reservation"}
	CancelReservation = Type{"cancel_reservation"}
)
View Source
var (
	ErrInvalidSortParam      = errors.New("invalid sort param")
	ErrInvalidDirectionParam = errors.New("invalid direction param")
)

Functions

This section is empty.

Types

type CreateDTO

type CreateDTO struct {
	Type        Type
	SenderID    int64
	ReceiverID  int64
	Amount      int64
	Description string
}

type ListParams

type ListParams struct {
	Pagination pagination.Params
	Sort       *sort.Sort
}

func NewListParams

func NewListParams(sortParam, directionParam string, params pagination.Params) (ListParams, error)

type Repository

type Repository interface {
	GetTransactionsByAccountID(ctx context.Context, senderID int64, listParams ListParams) ([]Transaction, int, error)
}

type Service

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

func NewService

func NewService(repository Repository, logger *zap.Logger) *Service

func (*Service) GetTransactionsByAccountID

func (s *Service) GetTransactionsByAccountID(
	ctx context.Context,
	accountID int64,
	listParams ListParams,
) ([]Transaction, int, error)

type Transaction

type Transaction struct {
	TransactionID int64
	Type          Type
	SenderID      int64
	ReceiverID    int64
	Amount        int64
	Description   string
	CreatedAt     time.Time
}

type Type

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

func (*Type) Scan

func (t *Type) Scan(value interface{}) error

func (Type) String

func (t Type) String() string

func (Type) Value

func (t Type) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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