WA-10 - Implemented transactions

This commit is contained in:
Fran Jurmanović
2021-05-16 17:43:58 +02:00
parent 55010c83d6
commit a99b44194a
8 changed files with 251 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
package services
import (
"wallet-api/pkg/models"
"wallet-api/pkg/utl/common"
"github.com/go-pg/pg/v10"
)
type TransactionTypeService struct {
Db *pg.DB
}
func (as *TransactionTypeService) New(body *models.NewTransactionTypeBody) *models.TransactionType {
tm := new(models.TransactionType)
tm.Init()
tm.Name = body.Name
tm.Type = body.Type
as.Db.Model(tm).Insert()
return tm
}
func (as *TransactionTypeService) GetAll(embed string) *[]models.TransactionType {
wm := new([]models.TransactionType)
query := as.Db.Model(wm)
common.GenerateEmbed(query, embed).Select()
return wm
}