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

import (
	"context"
	"fmt"

	"github.com/gocql/gocql"

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

type GetTagByIDUseCase struct {
	tagRepo dom_tag.Repository
}

func NewGetTagByIDUseCase(tagRepo dom_tag.Repository) *GetTagByIDUseCase {
	return &GetTagByIDUseCase{
		tagRepo: tagRepo,
	}
}

func (uc *GetTagByIDUseCase) Execute(ctx context.Context, id gocql.UUID) (*dom_tag.Tag, error) {
	tag, err := uc.tagRepo.GetByID(ctx, id)
	if err != nil {
		return nil, fmt.Errorf("failed to get tag: %w", err)
	}

	return tag, nil
}
