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