added validation; DB is global now

This commit is contained in:
$(pass /github/name)
2024-07-11 20:59:52 +02:00
parent e4475e2400
commit 03a2b3bdc5
22 changed files with 287 additions and 218 deletions

View File

@@ -10,19 +10,15 @@ import (
"time"
)
type BankAccountService interface {
type BankAccountServiceInterface interface {
RegisterBankAccount(bankAccount *models.BankAccount) (int64, error)
}
type bankAccountService struct {
repo repositories.BankAccountRepository
type BankAccountService struct {
Repo repositories.BankAccountRepositoryInterface
}
func NewBankAccountService(repo repositories.BankAccountRepository) BankAccountService {
return &bankAccountService{repo}
}
func (service *bankAccountService) RegisterBankAccount(bankAccount *models.BankAccount) (int64, error) {
func (service *BankAccountService) RegisterBankAccount(bankAccount *models.BankAccount) (int64, error) {
bankAccount.MandateDateSigned = time.Now()
ref, err := generateSEPAMandateReference(strconv.FormatInt(bankAccount.UserID, 10))
if err != nil {
@@ -30,7 +26,7 @@ func (service *bankAccountService) RegisterBankAccount(bankAccount *models.BankA
}
bankAccount.MandateReference = ref
return service.repo.CreateBankAccount(bankAccount)
return service.Repo.CreateBankAccount(bankAccount)
}
func generateUniqueID(length int) (string, error) {