niki/domain/wallet/service/service.go

37 lines
1013 B
Go

package service
import (
"context"
"git.gocasts.ir/ebhomengo/niki/domain/wallet/entity"
"git.gocasts.ir/ebhomengo/niki/pkg/database/postgres"
"git.gocasts.ir/ebhomengo/niki/pkg/types"
"github.com/shopspring/decimal"
)
type CurrencyRateProvider interface {
GetCurrencyPriceRateInIRR(currency types.Currency) (decimal.Decimal, error)
}
type Repository interface {
GetTransactionListByUserID(ctx context.Context, UserID uint64, DBPagination postgres.DBPagination) ([]entity.Transaction, int64, error)
GetWalletByUserID(ctx context.Context, UserID uint64) (entity.Wallet, error)
InsertTransaction(ctx context.Context, transaction entity.Transaction, currencyRate decimal.Decimal) (decimal.Decimal, types.Currency, error)
}
type Config struct {
PageSize int64 `koanf:"page_size"`
}
type Service struct {
repo Repository
cfg Config
currencyRateProvider CurrencyRateProvider
}
func New(repo Repository, cfg Config) Service {
return Service{repo: repo, cfg: cfg}
}