package collection

import (
	"context"
	"tercul/internal/domain"
)

// CollectionQueries contains the query handlers for the collection aggregate.
type CollectionQueries struct {
	repo domain.CollectionRepository
}

// NewCollectionQueries creates a new CollectionQueries handler.
func NewCollectionQueries(repo domain.CollectionRepository) *CollectionQueries {
	return &CollectionQueries{repo: repo}
}

// Collection returns a collection by ID.
func (q *CollectionQueries) Collection(ctx context.Context, id uint) (*domain.Collection, error) {
	return q.repo.GetByID(ctx, id)
}

// CollectionsByUserID returns all collections for a user.
func (q *CollectionQueries) CollectionsByUserID(ctx context.Context, userID uint) ([]domain.Collection, error) {
	return q.repo.ListByUserID(ctx, userID)
}

// PublicCollections returns all public collections.
func (q *CollectionQueries) PublicCollections(ctx context.Context) ([]domain.Collection, error) {
	return q.repo.ListPublic(ctx)
}

// CollectionsByWorkID returns all collections for a work.
func (q *CollectionQueries) CollectionsByWorkID(ctx context.Context, workID uint) ([]domain.Collection, error) {
	return q.repo.ListByWorkID(ctx, workID)
}

// Collections returns all collections.
func (q *CollectionQueries) Collections(ctx context.Context) ([]domain.Collection, error) {
	return q.repo.ListAll(ctx)
}
