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

ru.foodtechlab.lib.auth.service.domain.roleAccess.usecase.GenerateGodModAccessUseCase Maven / Gradle / Ivy

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

import com.rcore.domain.commons.usecase.UseCase;
import com.rcore.domain.commons.usecase.model.SingleOutput;
import com.rcore.domain.commons.usecase.model.VoidInputValues;
import lombok.RequiredArgsConstructor;
import ru.foodtechlab.lib.auth.service.domain.roleAccess.entity.RoleAccessEntity;
import ru.foodtechlab.lib.auth.service.domain.roleAccess.port.RoleAccessIdGenerator;
import ru.foodtechlab.lib.auth.service.domain.roleAccess.port.RoleAccessRepository;

@RequiredArgsConstructor
public class GenerateGodModAccessUseCase extends UseCase> {

    private final RoleAccessRepository repository;
    private final RoleAccessIdGenerator idGenerator;

    @Override
    public SingleOutput execute(VoidInputValues voidInputValues) {
        return SingleOutput.of(repository.findGodModeAccess()
                .orElseGet(() -> {
                    var access = RoleAccessEntity.createGodMode();
                    access.setId(idGenerator.generate());
                    repository.save(access);
                    return access;
                }));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy