example

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2018 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Balance int
	UserID  int64
}

Account entity

func (*Account) Deposit

func (a *Account) Deposit(amount int)

Deposit deposits amount to the account

func (*Account) Withdraw

func (a *Account) Withdraw(amount int) error

Withdraw withdraws the amount from account if available

type AccountRepository

type AccountRepository interface {
	tx.Transactional // Embed interface inside of a repo or inject it separately through NewAccountService constructor

	ByID(context.Context, int64) (*Account, error)
	Save(context.Context, *Account) error
}

AccountRepository represents account repository interface

type AccountService

type AccountService struct {
	tx.Transactional // A convenience so we can use .RunTx directly on a service (mimick @Transactional)
	// contains filtered or unexported fields
}

AccountService represents account application service

func NewAccountService

func NewAccountService(accRepo AccountRepository) *AccountService

NewAccountService creates new account application service instance

func (*AccountService) TransferMoney

func (svc *AccountService) TransferMoney(ctx context.Context, req *TransferReq) error

TransferMoney transfers the amount from source account to destination account

type TransferReq

type TransferReq struct {
	SrcID  int64
	DestID int64
	Amount int
}

TransferReq DTO

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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