added validation; DB is global now
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user