ru.foodtechlab.lib.auth.service.domain.credential.usecases.FindCredentialByEmailUseCase Maven / Gradle / Ivy
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