package de.effigenix.infrastructure.stub;

import de.effigenix.domain.masterdata.customer.Customer;
import de.effigenix.domain.masterdata.customer.CustomerId;
import de.effigenix.domain.masterdata.customer.CustomerName;
import de.effigenix.domain.masterdata.customer.CustomerRepository;
import de.effigenix.domain.masterdata.customer.CustomerStatus;
import de.effigenix.domain.masterdata.customer.CustomerType;
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 StubCustomerRepository implements CustomerRepository {

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

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

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

    @Override
    public Result<RepositoryError, List<Customer>> findByType(CustomerType type) {
        return Result.failure(STUB_ERROR);
    }

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

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

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

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