package de.effigenix.infrastructure.stub;

import de.effigenix.domain.inventory.StorageLocation;
import de.effigenix.domain.inventory.StorageLocationId;
import de.effigenix.domain.inventory.StorageLocationName;
import de.effigenix.domain.inventory.StorageLocationRepository;
import de.effigenix.domain.inventory.StorageType;
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 StubStorageLocationRepository implements StorageLocationRepository {

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

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

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

    @Override
    public Result<RepositoryError, List<StorageLocation>> findByStorageType(StorageType storageType) {
        return Result.failure(STUB_ERROR);
    }

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

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

    @Override
    public Result<RepositoryError, Boolean> existsByNameAndIdNot(StorageLocationName name, StorageLocationId id) {
        return Result.failure(STUB_ERROR);
    }

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