package de.effigenix.infrastructure.stub;

import de.effigenix.domain.usermanagement.User;
import de.effigenix.domain.usermanagement.UserId;
import de.effigenix.domain.usermanagement.UserRepository;
import de.effigenix.domain.usermanagement.UserStatus;
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 StubUserRepository implements UserRepository {

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

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

    @Override
    public Result<RepositoryError, Optional<User>> findByUsername(String username) {
        return Result.failure(STUB_ERROR);
    }

    @Override
    public Result<RepositoryError, Optional<User>> findByEmail(String email) {
        return Result.failure(STUB_ERROR);
    }

    @Override
    public Result<RepositoryError, List<User>> findByBranchId(String branchId) {
        return Result.failure(STUB_ERROR);
    }

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

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

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

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

    @Override
    public Result<RepositoryError, Boolean> existsByUsername(String username) {
        return Result.failure(STUB_ERROR);
    }

    @Override
    public Result<RepositoryError, Boolean> existsByEmail(String email) {
        return Result.failure(STUB_ERROR);
    }
}
