transaction

package
v0.0.0-...-23038bb Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrValidationFailed        = errors.New("Validation Failed")
	ErrValidationFailedCode    = "TRANSACTION_0001"
	ErrInvalidQueryCode        = "TRANSACTION_0002"
	ErrTransactionNotFound     = errors.New("Transaction Not Found")
	ErrTransactionNotFoundCode = "TRANSACTION_0004"
)

Functions

func GetQuery

func GetQuery(p GetParam, db *sql.DB) (*sql.Rows, *sql.Row, error)

func RegisterHandler

func RegisterHandler(r *gin.Engine, db *sql.DB, service Service)

Types

type CreateDto

type CreateDto struct {
	Amount      int64  `form:"amount"`
	Description string `form:"description"`
	Category    string `form:"category"`
	Type        string `form:"type"`
}

func NewCreateDtoFromRequest

func NewCreateDtoFromRequest(c *gin.Context) CreateDto

func (CreateDto) Validate

func (dto CreateDto) Validate() validator.Validate

type GetParam

type GetParam struct {
	DateRange getrange.Range
	Page      int
	PerPage   int
	UserId    string
	Category  string
	Type      string
}

type GetTotalParam

type GetTotalParam struct {
	Category string
	UserId   string
	Range    getrange.Range
}

type Repository

type Repository interface {
	Get(p GetParam) ([]entity.Transaction, int, error)
	GetTotal(p GetTotalParam) (entity.TotalAmount, error)
	Create(t entity.Transaction) (entity.Transaction, error)
	FindOneById(id, userId string) (entity.Transaction, error)
	DeleteOneById(id, userId string) error
	UpdateOneById(id, userId string, dto UpdateDto) (entity.Transaction, error)
}

func NewRepository

func NewRepository(db *sql.DB) Repository

type Service

type Service interface {
	Create(t entity.Transaction) (entity.Transaction, error)
	FindOneById(id, userId string) (entity.Transaction, error)
	DeleteOneById(id, userId string) error
	UpdateOneById(id, userId string, dto UpdateDto) (entity.Transaction, error)
	Get(p GetParam) ([]entity.Transaction, int, error)
	GetTotal(p GetTotalParam) (entity.TotalAmount, error)
}

func NewService

func NewService(repo Repository) Service

type TransactionFilterQuery

type TransactionFilterQuery struct {
	Type     string
	Category string
}

func NewTransactionFilterQueryFromRequest

func NewTransactionFilterQueryFromRequest(c *gin.Context) TransactionFilterQuery

type UpdateDto

type UpdateDto struct {
	Amount      int64  `form:"amount"`
	Description string `form:"description"`
	Category    string `form:"category"`
	Type        string `form:"type"`
}

func NewUpdateDtoFromRequest

func NewUpdateDtoFromRequest(c *gin.Context) UpdateDto

func (UpdateDto) Validate

func (dto UpdateDto) Validate() validator.Validate

Jump to

Keyboard shortcuts

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