splitted user registration into user, consents & bankaccount creation

This commit is contained in:
$(pass /github/name)
2024-07-07 21:39:58 +02:00
parent a76d73aa82
commit 555d1be575
13 changed files with 270 additions and 53 deletions

View File

@@ -0,0 +1,35 @@
package repositories
import (
"GoMembership/internal/models"
// "GoMembership/pkg/errors"
"database/sql"
)
type ConsentRepository interface {
CreateConsent(consent *models.Consent) (int64, error)
}
type consentRepository struct {
db *sql.DB
}
func NewConsentRepository(db *sql.DB) ConsentRepository {
return &consentRepository{db}
}
func (repo *consentRepository) CreateConsent(consent *models.Consent) (int64, error) {
query := "INSERT INTO consents (user_id, first_name, last_name, email, created_at, updated_at, consent_type) VALUES (?, ?, ?, ?, ?, ?, ?)"
result, err := repo.db.Exec(query, consent.UserID, consent.FirstName, consent.LastName, consent.Email, consent.CreatedAt, consent.UpdatedAt, consent.ConsentType)
if err != nil {
return -1, err
}
lastInsertID, err := result.LastInsertId()
if err != nil {
return -1, err
}
return lastInsertID, err
}