package tag

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

// TagQueries contains the query handlers for the tag aggregate.
type TagQueries struct {
	repo domain.TagRepository
}

// NewTagQueries creates a new TagQueries handler.
func NewTagQueries(repo domain.TagRepository) *TagQueries {
	return &TagQueries{repo: repo}
}

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

// TagByName returns a tag by name.
func (q *TagQueries) TagByName(ctx context.Context, name string) (*domain.Tag, error) {
	return q.repo.FindByName(ctx, name)
}

// TagsByWorkID returns all tags for a work.
func (q *TagQueries) TagsByWorkID(ctx context.Context, workID uint) ([]domain.Tag, error) {
	return q.repo.ListByWorkID(ctx, workID)
}

// Tags returns all tags.
func (q *TagQueries) Tags(ctx context.Context) ([]domain.Tag, error) {
	return q.repo.ListAll(ctx)
}
