splitted user registration into user, consents & bankaccount creation
This commit is contained in:
35
internal/repositories/consents_repository.go
Normal file
35
internal/repositories/consents_repository.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user