// codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/internal/usecase/tag/listbyuser.go
package tag

import (
	"context"
	"fmt"

	"github.com/gocql/gocql"

	dom_tag "codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/internal/domain/tag"
)

type ListTagsByUserUseCase struct {
	tagRepo dom_tag.Repository
}

func NewListTagsByUserUseCase(tagRepo dom_tag.Repository) *ListTagsByUserUseCase {
	return &ListTagsByUserUseCase{
		tagRepo: tagRepo,
	}
}

func (uc *ListTagsByUserUseCase) Execute(ctx context.Context, userID gocql.UUID) ([]*dom_tag.Tag, error) {
	tags, err := uc.tagRepo.ListByUser(ctx, userID)
	if err != nil {
		return nil, fmt.Errorf("failed to list tags: %w", err)
	}

	return tags, nil
}
