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 ConsentRepository interface {
type ConsentRepositoryInterface interface {
CreateConsent(consent *models.Consent) (int64, error)
}
type consentRepository struct {
db *gorm.DB
}
type ConsentRepository struct{}
func NewConsentRepository(db *gorm.DB) ConsentRepository {
return &consentRepository{db}
}
func (repo *consentRepository) CreateConsent(consent *models.Consent) (int64, error) {
result := repo.db.Create(consent)
func (repo *ConsentRepository) CreateConsent(consent *models.Consent) (int64, error) {
result := database.DB.Create(consent)
if result.Error != nil {
return 0, result.Error