service

package
v0.0.0-...-1caa4a4 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

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

Account service contains business logic related to model.Account.

func NewAccount

func NewAccount(
	persistentStorage *sqlite.Account,
	inmemoryStorage *inmemory.Account,
	currencyService *Currency) (*Account, error)

NewAccount returns Account service.

func (*Account) Delete

func (s *Account) Delete(a *model.Account) error

Delete deletes account from inmemory and persistent storages.

func (*Account) GetAll

func (s *Account) GetAll() []*model.Account

GetAll returns all accounts.

func (*Account) GetByID

func (s *Account) GetByID(id int64) *model.Account

GetByID returns account by given model.Account.ID.

func (*Account) GetByName

func (s *Account) GetByName(name string) *model.Account

GetByName returns currency by given model.Account.Name.

func (*Account) Init

func (s *Account) Init(currencyService *Currency) error

Init initialize inmemory storage with data from persistent storage. It is also links existing currencies to corresponding fields of model.Account.

func (*Account) Insert

func (s *Account) Insert(a *model.Account) error

Insert appends account to both persistent and inmemory storages.

func (*Account) Update

func (s *Account) Update(a *model.Account) error

Update updates account in persistent storage. Since GetAll returns pointers to inmemory data after update the category we need to update it in persistent storage as well.

type Category

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

Category service contains business logic related to model.Category.

func NewCategory

func NewCategory(persistentStorage *sqlite.Category, inmemoryStorage *inmemory.Category) (*Category, error)

NewCategory returns Category service.

func (*Category) Delete

func (s *Category) Delete(c *model.Category) error

Delete deletes category from inmemory and persistent storages.

func (*Category) GetAll

func (s *Category) GetAll() []*model.Category

GetAll returns all categories.

func (*Category) GetByID

func (s *Category) GetByID(id int64) *model.Category

GetByID returns category by given model.Category.ID.

func (*Category) GetByTitle

func (s *Category) GetByTitle(title string) *model.Category

GetByTitle returns category by given model.Category.Title.

func (*Category) Init

func (s *Category) Init() error

Init initialize inmemory storage with data from persistent storage.

func (*Category) Insert

func (s *Category) Insert(c *model.Category) error

Insert appends category to both persistent and inmemory storages.

func (*Category) Update

func (s *Category) Update(c *model.Category) error

Update updates category in persistent storage. Since GetAll returns pointers to inmemory data after update the category we need to update it in persistent storage as well.

type Currency

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

Currency service contains business logic related to model.Currency.

func NewCurrency

func NewCurrency(persistentStorage *sqlite.Currency, inmemoryStorage *inmemory.Currency) (*Currency, error)

NewCurrency returns Currency service.

func (*Currency) Delete

func (s *Currency) Delete(c *model.Currency) error

Delete deletes currency from inmemory and persistent storages.

func (*Currency) GetAll

func (s *Currency) GetAll() []*model.Currency

GetAll returns all currencies.

func (*Currency) GetByAbbreviation

func (s *Currency) GetByAbbreviation(abbreviation string) *model.Currency

GetByAbbreviation returns currency by given model.Currency.Abbreviation.

func (*Currency) GetByID

func (s *Currency) GetByID(id int64) *model.Currency

GetByID returns currency by given model.Currency.ID.

func (*Currency) Init

func (s *Currency) Init() error

Init initialize inmemory storage with data from persistent storage.

func (*Currency) Insert

func (s *Currency) Insert(c *model.Currency) error

Insert appends currency to both persistent and inmemory storages.

func (*Currency) Update

func (s *Currency) Update(c *model.Currency) error

Update updates currency in persistent storage. Since GetAll returns pointers to inmemory data after update the category we need to update it in persistent storage as well.

type Service

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

Service is a facade structure which aggregates all Services. It is used for convenience.

func New

func New(ps *sqlite.SqliteStorage, is *inmemory.InmemoryStorage) (s *Service, err error)

New returns new Service.

func (*Service) Account

func (s *Service) Account() *Account

Account returns account service.

func (*Service) Category

func (s *Service) Category() *Category

Category returns category service.

func (*Service) Currency

func (s *Service) Currency() *Currency

Currency returns currency service.

func (*Service) Transaction

func (s *Service) Transaction() *Transaction

Transaction returns transaction service.

type Transaction

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

Transaction service contains business logic related to model.Transaction.

func NewTransaction

func NewTransaction(
	persistentStorage *sqlite.Transaction,
	inmemoryStorage *inmemory.Transaction,
	categoryService *Category,
	accountService *Account) (*Transaction, error)

NewCurrency returns Transaction service.

func (*Transaction) Delete

func (s *Transaction) Delete(t *model.Transaction) error

Delete deletes transaction from inmemory and persistent storages.

func (*Transaction) GetAll

func (s *Transaction) GetAll() []*model.Transaction

GetAll returns all transactions.

func (*Transaction) GetByID

func (s *Transaction) GetByID(id int64) *model.Transaction

GetByID returns transaction by given model.Transaction.ID.

func (*Transaction) Init

func (s *Transaction) Init(categoryService *Category, accountService *Account) error

Init initialize inmemory storage with data from persistent storage. It is also links existing categories and accounts to corresponding fields of model.Transaction.

func (*Transaction) Insert

func (s *Transaction) Insert(t *model.Transaction) error

Insert appends transaction to both persistent and inmemory storages.

func (*Transaction) Update

func (s *Transaction) Update(t *model.Transaction) error

Update updates transaction in persistent and inmemory storages.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳