package de.effigenix.infrastructure.stub;

import de.effigenix.domain.masterdata.supplier.Supplier;
import de.effigenix.domain.masterdata.supplier.SupplierId;
import de.effigenix.domain.masterdata.supplier.SupplierName;
import de.effigenix.domain.masterdata.supplier.SupplierRepository;
import de.effigenix.domain.masterdata.supplier.SupplierStatus;
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 StubSupplierRepository implements SupplierRepository {

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

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

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

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

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

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

    @Override
    public Result<RepositoryError, Boolean> existsByName(SupplierName name) {
        return Result.failure(STUB_ERROR);
    }
}
