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
}
