Initial commit: Open sourcing all of the Maple Open Technologies code.

This commit is contained in:
Bartlomiej Mika 2025-12-02 14:33:08 -05:00
commit 755d54a99d
2010 changed files with 448675 additions and 0 deletions

View file

@ -0,0 +1,54 @@
// monorepo/cloud/backend/internal/maplefile/usecase/collection/find_descendants.go
package collection
import (
"context"
"go.uber.org/zap"
"github.com/gocql/gocql"
"codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/config"
dom_collection "codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/internal/domain/collection"
"codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/pkg/httperror"
)
type FindDescendantsUseCase interface {
Execute(ctx context.Context, collectionID gocql.UUID) ([]*dom_collection.Collection, error)
}
type findDescendantsUseCaseImpl struct {
config *config.Configuration
logger *zap.Logger
repo dom_collection.CollectionRepository
}
func NewFindDescendantsUseCase(
config *config.Configuration,
logger *zap.Logger,
repo dom_collection.CollectionRepository,
) FindDescendantsUseCase {
logger = logger.Named("FindDescendantsUseCase")
return &findDescendantsUseCaseImpl{config, logger, repo}
}
func (uc *findDescendantsUseCaseImpl) Execute(ctx context.Context, collectionID gocql.UUID) ([]*dom_collection.Collection, error) {
//
// STEP 1: Validation.
//
e := make(map[string]string)
if collectionID.String() == "" {
e["collection_id"] = "Collection ID is required"
}
if len(e) != 0 {
uc.logger.Warn("Failed validating find descendants",
zap.Any("error", e))
return nil, httperror.NewForBadRequest(&e)
}
//
// STEP 2: Find descendants.
//
return uc.repo.FindDescendants(ctx, collectionID)
}