package de.effigenix.infrastructure.stub;

import de.effigenix.domain.masterdata.productcategory.CategoryName;
import de.effigenix.domain.masterdata.productcategory.ProductCategory;
import de.effigenix.domain.masterdata.productcategory.ProductCategoryId;
import de.effigenix.domain.masterdata.productcategory.ProductCategoryRepository;
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 StubProductCategoryRepository implements ProductCategoryRepository {

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

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

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

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

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

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