Documentation
¶
Overview ¶
Package account provides business logic for interacting with domain entities such as accounts and transactions. It defines the Service struct and its methods for creating accounts, depositing and withdrawing funds, retrieving account details, listing transactions, and checking account balances.
The service layer follows clean architecture principles and uses the decorator pattern for transaction management. All business operations are wrapped with automatic transaction management,
error recovery, and structured logging.
Index ¶
- type Service
- func (s *Service) CreateAccount(ctx context.Context, create dto.AccountCreate) (*dto.AccountRead, error)
- func (s *Service) Deposit(ctx context.Context, cmd commands.Deposit) error
- func (s *Service) GetAccount(ctx context.Context, userID, accountID uuid.UUID) (account *dto.AccountRead, err error)
- func (s *Service) GetBalance(ctx context.Context, userID, accountID uuid.UUID) (balance float64, err error)
- func (s *Service) GetTransactions(ctx context.Context, userID, accountID uuid.UUID) (transactions []*dto.TransactionRead, err error)
- func (s *Service) ListUserAccounts(ctx context.Context, userID uuid.UUID) ([]*dto.AccountRead, error)
- func (s *Service) Transfer(ctx context.Context, cmd commands.Transfer) error
- func (s *Service) Withdraw(ctx context.Context, cmd commands.Withdraw) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides business logic for account operations including creation, deposits, withdrawals, and balance inquiries.
func New ¶
func New( bus eventbus.Bus, uow repository.UnitOfWork, logger *slog.Logger, stripeConnectSvc stripeconnect.Service, ) *Service
New creates a new Service with the provided dependencies.
func (*Service) CreateAccount ¶
func (s *Service) CreateAccount( ctx context.Context, create dto.AccountCreate, ) (*dto.AccountRead, error)
func (*Service) Deposit ¶
Deposit adds funds to the specified account and creates a transaction record.
func (*Service) GetAccount ¶
func (s *Service) GetAccount( ctx context.Context, userID, accountID uuid.UUID, ) ( account *dto.AccountRead, err error, )
GetAccount retrieves an account by ID for the specified user.
func (*Service) GetBalance ¶
func (s *Service) GetBalance( ctx context.Context, userID, accountID uuid.UUID, ) ( balance float64, err error, )
GetBalance retrieves the current balance of an account for the specified user.
func (*Service) GetTransactions ¶
func (s *Service) GetTransactions( ctx context.Context, userID, accountID uuid.UUID, ) ( transactions []*dto.TransactionRead, err error, )
GetTransactions retrieves all transactions for a specific account.
func (*Service) ListUserAccounts ¶ added in v1.4.0
func (s *Service) ListUserAccounts( ctx context.Context, userID uuid.UUID, ) ([]*dto.AccountRead, error)
ListUserAccounts returns all accounts for a specific user.