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 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
|
||||
|
||||
Reference in New Issue
Block a user