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

@@ -1,24 +1,18 @@
package repositories
import (
"GoMembership/internal/database"
"GoMembership/internal/models"
"gorm.io/gorm"
)
type BankAccountRepository interface {
type BankAccountRepositoryInterface interface {
CreateBankAccount(account *models.BankAccount) (int64, error)
}
type bankAccountRepository struct {
db *gorm.DB
}
type BankAccountRepository struct{}
func NewBankAccountRepository(db *gorm.DB) BankAccountRepository {
return &bankAccountRepository{db}
}
func (repo *bankAccountRepository) CreateBankAccount(account *models.BankAccount) (int64, error) {
result := repo.db.Create(account)
func (repo *BankAccountRepository) CreateBankAccount(account *models.BankAccount) (int64, error) {
result := database.DB.Create(account)
if result.Error != nil {
return 0, result.Error
}