package de.effigenix.infrastructure.stub;

import de.effigenix.domain.masterdata.article.Article;
import de.effigenix.domain.masterdata.article.ArticleId;
import de.effigenix.domain.masterdata.article.ArticleNumber;
import de.effigenix.domain.masterdata.article.ArticleRepository;
import de.effigenix.domain.masterdata.article.ArticleStatus;
import de.effigenix.domain.masterdata.productcategory.ProductCategoryId;
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 StubArticleRepository implements ArticleRepository {

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

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

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

    @Override
    public Result<RepositoryError, List<Article>> findByCategory(ProductCategoryId categoryId) {
        return Result.failure(STUB_ERROR);
    }

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

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

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

    @Override
    public Result<RepositoryError, Boolean> existsByArticleNumber(ArticleNumber articleNumber) {
        return Result.failure(STUB_ERROR);
    }
}
