package de.effigenix.infrastructure.stub;

import de.effigenix.domain.production.ProductionOrder;
import de.effigenix.domain.production.ProductionOrderId;
import de.effigenix.domain.production.ProductionOrderRepository;
import de.effigenix.domain.production.ProductionOrderStatus;
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 StubProductionOrderRepository implements ProductionOrderRepository {

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

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

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

    @Override
    public Result<RepositoryError, List<ProductionOrder>> findByDateRange(LocalDate from, LocalDate to) {
        return Result.failure(STUB_ERROR);
    }

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

    @Override
    public Result<RepositoryError, List<ProductionOrder>> findByDateRangeAndStatus(LocalDate from, LocalDate to, ProductionOrderStatus status) {
        return Result.failure(STUB_ERROR);
    }

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