All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.foodtechlab.lib.auth.service.domain.credential.usecases.FindCredentialByEmailUseCase Maven / Gradle / Ivy

There is a newer version: 4.1.0
Show newest version
package ru.foodtechlab.lib.auth.service.domain.credential.usecases;

import com.rcore.commons.utils.StringUtils;
import com.rcore.domain.commons.usecase.UseCase;
import com.rcore.domain.commons.usecase.model.SingleOutput;
import com.rcore.domain.commons.validators.ValidationDomain;
import lombok.RequiredArgsConstructor;
import lombok.Value;
import ru.foodtechlab.lib.auth.service.domain.Domain;
import ru.foodtechlab.lib.auth.service.domain.auth.validation.payload.InvalidEmailPayload;
import ru.foodtechlab.lib.auth.service.domain.credential.entity.CredentialEntity;
import ru.foodtechlab.lib.auth.service.domain.credential.port.CredentialRepository;

import javax.validation.constraints.NotBlank;
import java.util.Optional;

@RequiredArgsConstructor
public class FindCredentialByEmailUseCase extends UseCase>> {

    private final CredentialRepository credentialRepository;

    @Override
    public SingleOutput> execute(InputValues inputValues) {
        if (inputValues.getEmail() == null || !StringUtils.hasText(inputValues.getEmail()))
            return SingleOutput.of(Optional.empty());

        return SingleOutput.of(credentialRepository.findByEmail(inputValues.getEmail()));
    }

    @ValidationDomain(domainName = Domain.CREDENTIAL)
    @Value(staticConstructor = "of")
    public static class InputValues implements UseCase.InputValues {
        String email;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy