package de.effigenix.infrastructure.stub;

import de.effigenix.domain.production.Recipe;
import de.effigenix.domain.production.RecipeId;
import de.effigenix.domain.production.RecipeRepository;
import de.effigenix.domain.production.RecipeStatus;
import de.effigenix.shared.common.RepositoryError;
import de.effigenix.shared.common.Result;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
@Profile("no-db")
public class StubRecipeRepository implements RecipeRepository {

    private static final RepositoryError.DatabaseError STUB_ERROR =
            new RepositoryError.DatabaseError("Stub-Modus: keine Datenbankverbindung");

    @Override
    public Result<RepositoryError, Optional<Recipe>> findById(RecipeId id) {
        return Result.failure(STUB_ERROR);
    }

    @Override
    public Result<RepositoryError, List<Recipe>> findAll() {
        return Result.failure(STUB_ERROR);
    }

    @Override
    public Result<RepositoryError, Void> save(Recipe recipe) {
        return Result.failure(STUB_ERROR);
    }

    @Override
    public Result<RepositoryError, Void> delete(Recipe recipe) {
        return Result.failure(STUB_ERROR);
    }

    @Override
    public Result<RepositoryError, Boolean> existsByNameAndVersion(String name, int version) {
        return Result.failure(STUB_ERROR);
    }

    @Override
    public Result<RepositoryError, List<Recipe>> findByStatus(RecipeStatus status) {
        return Result.failure(STUB_ERROR);
    }

    @Override
    public Result<RepositoryError, List<Recipe>> findByArticleId(String articleId) {
        return Result.failure(STUB_ERROR);
    }
}
