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

ru.foodtechlab.lib.auth.service.domain.preference.usecase.CreateServicePreferenceUseCase Maven / Gradle / Ivy

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

import com.rcore.domain.commons.usecase.AbstractCreateUseCase;
import com.rcore.domain.commons.usecase.UseCase;
import com.rcore.domain.commons.usecase.model.SingletonEntityOutputValues;
import lombok.Builder;
import lombok.Value;
import ru.foodtechlab.lib.auth.service.domain.confirmationCode.entity.ConfirmationCodeEntity;
import ru.foodtechlab.lib.auth.service.domain.preference.entity.*;
import ru.foodtechlab.lib.auth.service.domain.preference.port.ServicePreferenceIdGenerator;
import ru.foodtechlab.lib.auth.service.domain.preference.port.ServicePreferenceRepository;

public class CreateServicePreferenceUseCase
        extends AbstractCreateUseCase, ServicePreferenceRepository, CreateServicePreferenceUseCase.InputValues> {

    public CreateServicePreferenceUseCase(ServicePreferenceRepository repository, ServicePreferenceIdGenerator idGenerator) {
        super(repository, idGenerator);
    }

    @Override
    public SingletonEntityOutputValues execute(InputValues inputValues) {
        var settings = new ServicePreferenceEntity();
        settings.setId(idGenerator.generate());
        settings.setGeneralConfirmationCode(inputValues.getGeneralConfirmationCode());
        settings.setDefaultRoleCode(inputValues.getDefaultRoleCode());
        settings.setDefaultIsoTwoLetterCountryCode(inputValues.getDefaultIsoTwoLetterCountryCode());
        settings.setDefaultPersonalConfirmationCode(inputValues.getDefaultPersonalConfirmationCode());
        settings.setDefaultConfirmationCodeType(inputValues.getDefaultConfirmationCodeType());
        settings.setConfirmationCodeDayAttemptLimits(inputValues.getConfirmationCodeDayAttemptLimits());
        settings.setDeviceIdDayAttemptLimits(inputValues.getDeviceIdDayAttemptLimits());
        settings.setIpV4HourAttemptLimits(inputValues.getIpV4HourAttemptLimits());
        settings.setAuthSessionWithConfirmationTTLs(inputValues.getAuthSessionWithConfirmationTTLs());
        settings.setConfirmationCodeMessageBodies(inputValues.getConfirmationCodeMessageBodies());
        settings.setAuthSessionLoginConfirmAttemptsLimits(inputValues.getAuthSessionLoginConfirmAttemptsLimits());
        settings.setDefaultConfirmationCodeMessageWebhookProviders(inputValues.getDefaultConfirmationCodeMessageWebhookProviders());
        settings.setDefaultConfirmationCodeMessageBodies(inputValues.getDefaultConfirmationCodeMessageBodies());
        settings.setPasswordValidationHourAttemptLimits(inputValues.getPasswordValidationHourAttemptLimits());
        repository.save(settings);

        return SingletonEntityOutputValues.of(settings);
    }

    @Value
    @Builder
    public static class InputValues implements UseCase.InputValues {
        String defaultRoleCode;
        String defaultIsoTwoLetterCountryCode;
        String defaultPersonalConfirmationCode;
        String generalConfirmationCode;
        ConfirmationCodeEntity.Type defaultConfirmationCodeType;
        ConfirmationCodeDayAttemptLimit confirmationCodeDayAttemptLimits;
        AuthSessionTypeAttemptLimits deviceIdDayAttemptLimits;
        AuthSessionTypeAttemptLimits ipV4HourAttemptLimits;
        AuthSessionWithConfirmationTTLs authSessionWithConfirmationTTLs;
        ConfirmationCodeMessageBodies confirmationCodeMessageBodies;
        AttemptLimitsByLoginType authSessionLoginConfirmAttemptsLimits;
        ConfirmationCodeMessageWebhookProviders defaultConfirmationCodeMessageWebhookProviders;
        DefaultConfirmationCodeMessageBodies defaultConfirmationCodeMessageBodies;
        AttemptLimitsByLoginType passwordValidationHourAttemptLimits;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy