package comment

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

// CommentQueries contains the query handlers for the comment aggregate.
type CommentQueries struct {
	repo domain.CommentRepository
}

// NewCommentQueries creates a new CommentQueries handler.
func NewCommentQueries(repo domain.CommentRepository) *CommentQueries {
	return &CommentQueries{repo: repo}
}

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

// CommentsByUserID returns all comments for a user.
func (q *CommentQueries) CommentsByUserID(ctx context.Context, userID uint) ([]domain.Comment, error) {
	return q.repo.ListByUserID(ctx, userID)
}

// CommentsByWorkID returns all comments for a work.
func (q *CommentQueries) CommentsByWorkID(ctx context.Context, workID uint) ([]domain.Comment, error) {
	return q.repo.ListByWorkID(ctx, workID)
}

// CommentsByTranslationID returns all comments for a translation.
func (q *CommentQueries) CommentsByTranslationID(ctx context.Context, translationID uint) ([]domain.Comment, error) {
	return q.repo.ListByTranslationID(ctx, translationID)
}

// CommentsByParentID returns all comments for a parent.
func (q *CommentQueries) CommentsByParentID(ctx context.Context, parentID uint) ([]domain.Comment, error) {
	return q.repo.ListByParentID(ctx, parentID)
}

// Comments returns all comments.
func (q *CommentQueries) Comments(ctx context.Context) ([]domain.Comment, error) {
	return q.repo.ListAll(ctx)
}
