currency

package
v0.0.0-...-eecab09 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorCodeRepository = domainerrors.ErrorCodeApplication + domainerrors.ErrorCodeApplicationCurrency + iota
	ErrorCodeValidateInput
	ErrorCodeCast
)

Variables

View Source
var (
	ErrValidation         = errors.New("validation failed")
	ErrCastToEntityFailed = errors.New("cast to entity failed")
)

Functions

This section is empty.

Types

type CreatedInput

type CreatedInput struct {
	Name   string `json:"name"`
	Symbol string `json:"symbol"`
}

func (*CreatedInput) ToEntity

func (c *CreatedInput) ToEntity() *entity.Currency

func (*CreatedInput) Validate

func (c *CreatedInput) Validate() error

type DeletedInput

type DeletedInput struct {
	ID string `json:"id" validate:"required,alphanum,len=20"`
}

func (*DeletedInput) Validate

func (i *DeletedInput) Validate() error

type DetailGotInput

type DetailGotInput struct {
	ID string `json:"id" validate:"required,alphanum,len=20"`
}

func (*DetailGotInput) Validate

func (i *DetailGotInput) Validate() error

type IService

type IService interface {
	// Command
	CreateCurrency(ctx context.Context, currencyInfo *CreatedInput) (*Output, error)
	// AssignCurrency(ctx context.Context, currencyInfo *AssignedInput) (*Output, error)
	UpdateCurrency(ctx context.Context, currencyInfo *UpdatedInput) (*Output, error)
	DeleteCurrency(ctx context.Context, currencyInfo *DeletedInput) (*Output, error)
	// // Query
	GetCurrencyList(ctx context.Context, currencyInfo *ListGotInput) (*OutputList, error)
	GetCurrencyDetail(ctx context.Context, currencyInfo *DetailGotInput) (*Output, error)
}

type ListGotInput

type ListGotInput struct {
	Limit      int      `json:"limit"`
	Offset     int      `json:"offset"`
	FilterName string   `json:"filterName" validate:"omitempty,oneof=name"`
	SortFields []string `json:"sortFields" validate:"dive,oneof=id name updated_at created_at"`
	Dir        string   `json:"dir" validate:"oneof=asc desc"`
}

func (*ListGotInput) ToEntity

func (i *ListGotInput) ToEntity() *entity.Currency

func (*ListGotInput) ToSearchQuery

func (i *ListGotInput) ToSearchQuery() *domain.SearchQuery

func (*ListGotInput) Validate

func (i *ListGotInput) Validate() error

type Output

type Output struct {
	ID             string          `json:"id"`
	Name           string          `json:"name"`
	Symbol         string          `json:"symbol"`
	WalletBalances []WalletBalance `json:"walletBalances" `
	CreatedAt      time.Time       `json:"createdAt"`
	UpdatedAt      time.Time       `json:"updatedAt"`
	DeletedAt      time.Time       `json:"deletedAt"`
}

func NewOutput

func NewOutput(e *entity.Currency) *Output

type OutputList

type OutputList struct {
	Offset int64    `json:"offset"`
	Limit  int64    `json:"limit"`
	Total  int64    `json:"total"`
	Items  []Output `json:"items"`
}

func NewListOutput

func NewListOutput(e *domain.List) *OutputList

type ServiceImpl

type ServiceImpl struct {
	TransactionRepo domain.ITransactionRepo
	CurrencyRepo    repository.CurrencyRepository
	UserRepo        repository.UserRepository
	EventProducer   event.Producer
	// contains filtered or unexported fields
}

ServiceImpl -.

func NewServiceImpl

func NewServiceImpl(currencyRepo repository.CurrencyRepository, userRepo repository.UserRepository, transactionRepo domain.ITransactionRepo, eventProducer event.Producer, l pwlogger.Interface) *ServiceImpl

NewServiceImpl -.

func (*ServiceImpl) CreateCurrency

func (u *ServiceImpl) CreateCurrency(ctx context.Context, currencyInfo *CreatedInput) (*Output, error)

CreateCurrency creates a currency.

func (*ServiceImpl) DeleteCurrency

func (u *ServiceImpl) DeleteCurrency(ctx context.Context, currencyInfo *DeletedInput) (*Output, error)

DeleteCurrency deletes currency.

func (*ServiceImpl) GetCurrencyDetail

func (u *ServiceImpl) GetCurrencyDetail(ctx context.Context, currencyInfo *DetailGotInput) (*Output, error)

GetCurrencyDetail gets currency detail.

func (*ServiceImpl) GetCurrencyList

func (u *ServiceImpl) GetCurrencyList(ctx context.Context, currencyInfo *ListGotInput) (*OutputList, error)

GetCurrencyList gets currency list.

func (*ServiceImpl) UpdateCurrency

func (u *ServiceImpl) UpdateCurrency(ctx context.Context, currencyInfo *UpdatedInput) (*Output, error)

UpdateCurrency updates currency.

type UpdatedInput

type UpdatedInput struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Symbol string `json:"symbol"`
}

func (*UpdatedInput) ToEntity

func (c *UpdatedInput) ToEntity() *entity.Currency

func (*UpdatedInput) Validate

func (c *UpdatedInput) Validate() error

type WalletBalance

type WalletBalance struct {
	ID         string `json:"id"`
	WalletID   string `json:"walletId"`
	CurrencyID string `json:"currencyId"`
	Balance    uint   `json:"balance"`
	Decimal    uint   `json:"decimal"`
}

Jump to

Keyboard shortcuts

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