backend moved to separate directory
backend: deleted the old structure
This commit is contained in:
31
go-backend/internal/repositories/licence_repository.go
Normal file
31
go-backend/internal/repositories/licence_repository.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"GoMembership/internal/database"
|
||||
"GoMembership/internal/models"
|
||||
)
|
||||
|
||||
type LicenceInterface interface {
|
||||
FindCategoryByName(categoryName string) (models.Category, error)
|
||||
FindCategoriesByIDs(ids []uint) ([]models.Category, error)
|
||||
GetAllCategories() ([]models.Category, error)
|
||||
}
|
||||
|
||||
type LicenceRepository struct{}
|
||||
|
||||
func (r *LicenceRepository) GetAllCategories() ([]models.Category, error) {
|
||||
var categories []models.Category
|
||||
err := database.DB.Find(&categories).Error
|
||||
return categories, err
|
||||
}
|
||||
func (r *LicenceRepository) FindCategoriesByIDs(ids []uint) ([]models.Category, error) {
|
||||
var categories []models.Category
|
||||
err := database.DB.Where("id IN ?", ids).Find(&categories).Error
|
||||
return categories, err
|
||||
}
|
||||
|
||||
func (r *LicenceRepository) FindCategoryByName(categoryName string) (models.Category, error) {
|
||||
var category models.Category
|
||||
err := database.DB.Where("name = ?", categoryName).First(&category).Error
|
||||
return category, err
|
||||
}
|
||||
Reference in New Issue
Block a user