domain

package
v0.0.0-...-c606dee Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccountNotFound = errors.New("account not found")

	ErrAccountOriginNotFound = errors.New("account origin not found")

	ErrAccountDestinationNotFound = errors.New("account destination not found")

	ErrInsufficientBalance = errors.New("origin account does not have sufficient balance")
)
View Source
var (
	ErrRecipeNotFound = errors.New("recipe not found")
)
View Source
var (
	ErrUserNotFound = errors.New("user not found")
)

Functions

func IsValidUUID

func IsValidUUID(uuid string) bool

func NewUUID

func NewUUID() string

Types

type Account

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

func NewAccount

func NewAccount(ID AccountID, name, CPF string, balance Money, createdAt time.Time) Account

func NewAccountBalance

func NewAccountBalance(balance Money) Account

func (Account) Balance

func (a Account) Balance() Money

func (Account) CPF

func (a Account) CPF() string

func (Account) CreatedAt

func (a Account) CreatedAt() time.Time

func (*Account) Deposit

func (a *Account) Deposit(amount Money)

func (Account) ID

func (a Account) ID() AccountID

func (Account) Name

func (a Account) Name() string

func (*Account) Withdraw

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

type AccountID

type AccountID string

func (AccountID) String

func (a AccountID) String() string

type AccountRepository

type AccountRepository interface {
	Create(context.Context, Account) (Account, error)
	UpdateBalance(context.Context, AccountID, Money) error
	FindAll(context.Context) ([]Account, error)
	FindByID(context.Context, AccountID) (Account, error)
	FindBalance(context.Context, AccountID) (Account, error)
}

type Email

type Email string

func (Email) String

func (r Email) String() string

type Money

type Money int64

func (Money) Float64

func (m Money) Float64() float64

func (Money) Int64

func (m Money) Int64() int64

type Recipe

type Recipe struct {
	ID           RecipeID  `json:"id"`
	Name         string    `json:"name"`
	Tags         []string  `json:"tags"`
	Ingredients  []string  `json:"ingredients"`
	Instructions []string  `json:"instructions"`
	PublishedAt  time.Time `json:"publishedAt"`
}

func NewRecipe

func NewRecipe(ID RecipeID, name string, tags []string, ingredients []string, instructions []string, publishedAt time.Time) Recipe

type RecipeID

type RecipeID string

func (RecipeID) String

func (r RecipeID) String() string

type RecipeRepository

type RecipeRepository interface {
	Create(context.Context, Recipe) (Recipe, error)
	Update(context.Context, RecipeID, Recipe) (Recipe, error)
	FindAll(context.Context) ([]Recipe, error)
	FindByID(context.Context, RecipeID) (Recipe, error)
	Delete(context.Context, RecipeID) error
}

type Transfer

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

func NewTransfer

func NewTransfer(
	ID TransferID,
	accountOriginID AccountID,
	accountDestinationID AccountID,
	amount Money,
	createdAt time.Time,
) Transfer

func (Transfer) AccountDestinationID

func (t Transfer) AccountDestinationID() AccountID

func (Transfer) AccountOriginID

func (t Transfer) AccountOriginID() AccountID

func (Transfer) Amount

func (t Transfer) Amount() Money

func (Transfer) CreatedAt

func (t Transfer) CreatedAt() time.Time

func (Transfer) ID

func (t Transfer) ID() TransferID

type TransferID

type TransferID string

func (TransferID) String

func (t TransferID) String() string

type TransferRepository

type TransferRepository interface {
	Create(context.Context, Transfer) (Transfer, error)
	FindAll(context.Context) ([]Transfer, error)
	WithTransaction(context.Context, func(context.Context) error) error
}

type User

type User struct {
	ID        UserID    `json:"id"`
	Email     string    `json:"email"`
	Password  string    `json:"password"`
	CreatedAt time.Time `json:"createdAt"`
}

func NewUser

func NewUser(ID UserID, name string, password string, createdAt time.Time) User

type UserID

type UserID string

func (UserID) String

func (r UserID) String() string

type UserRepository

type UserRepository interface {
	Create(context.Context, User) (User, error)
	Update(context.Context, UserID, User) (User, error)
	FindAll(context.Context) ([]User, error)
	FindByEmail(context.Context, Email) (User, error)
	FindByEmailAndPass(context context.Context, email string, password string) (User, error)
	FindByID(context.Context, UserID) (User, error)
	Delete(context.Context, UserID) error
}

Jump to

Keyboard shortcuts

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