package de.effigenix.infrastructure.stub;

import de.effigenix.domain.inventory.Stock;
import de.effigenix.domain.inventory.StockId;
import de.effigenix.domain.inventory.StockRepository;
import de.effigenix.domain.inventory.StorageLocationId;
import de.effigenix.domain.masterdata.article.ArticleId;
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.time.LocalDate;
import java.util.List;
import java.util.Optional;

@Repository
@Profile("no-db")
public class StubStockRepository implements StockRepository {

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

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

    @Override
    public Result<RepositoryError, Optional<Stock>> findByArticleIdAndStorageLocationId(ArticleId articleId, StorageLocationId storageLocationId) {
        return Result.failure(STUB_ERROR);
    }

    @Override
    public Result<RepositoryError, Boolean> existsByArticleIdAndStorageLocationId(ArticleId articleId, StorageLocationId storageLocationId) {
        return Result.failure(STUB_ERROR);
    }

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

    @Override
    public Result<RepositoryError, List<Stock>> findAllByStorageLocationId(StorageLocationId storageLocationId) {
        return Result.failure(STUB_ERROR);
    }

    @Override
    public Result<RepositoryError, List<Stock>> findAllByArticleId(ArticleId articleId) {
        return Result.failure(STUB_ERROR);
    }

    @Override
    public Result<RepositoryError, List<Stock>> findAllWithExpiryRelevantBatches(LocalDate referenceDate) {
        return Result.failure(STUB_ERROR);
    }

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

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