28 lines
519 B
Go
28 lines
519 B
Go
package repositories
|
|
|
|
import (
|
|
"GoMembership/internal/models"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type ConsentRepository interface {
|
|
CreateConsent(consent *models.Consent) (int64, error)
|
|
}
|
|
|
|
type consentRepository struct {
|
|
db *gorm.DB
|
|
}
|
|
|
|
func NewConsentRepository(db *gorm.DB) ConsentRepository {
|
|
return &consentRepository{db}
|
|
}
|
|
|
|
func (repo *consentRepository) CreateConsent(consent *models.Consent) (int64, error) {
|
|
result := repo.db.Create(consent)
|
|
|
|
if result.Error != nil {
|
|
return 0, result.Error
|
|
}
|
|
return consent.ID, nil
|
|
}
|