ru.foodtechlab.lib.auth.service.domain.role.config.RoleConfig Maven / Gradle / Ivy
package ru.foodtechlab.lib.auth.service.domain.role.config;
import com.rcore.event.driven.EventDispatcher;
import lombok.Getter;
import lombok.experimental.Accessors;
import ru.foodtechlab.lib.auth.service.domain.preference.usecase.GetServicePreferenceUseCase;
import ru.foodtechlab.lib.auth.service.domain.role.event.handler.RoleAccessDeletedHandler;
import ru.foodtechlab.lib.auth.service.domain.role.port.RoleIdGenerator;
import ru.foodtechlab.lib.auth.service.domain.role.port.RoleRepository;
import ru.foodtechlab.lib.auth.service.domain.role.usecases.*;
import ru.foodtechlab.lib.auth.service.domain.roleAccess.event.RoleAccessDeletedEvent;
import ru.foodtechlab.lib.auth.service.domain.roleAccess.port.RoleAccessRepository;
import ru.foodtechlab.lib.auth.service.domain.roleAccess.usecase.GenerateGodModAccessUseCase;
@Accessors(fluent = true)
@Getter
public class RoleConfig {
private final CreateRoleUseCase createRole;
private final FindRoleByIdUseCase findRoleById;
private final FindRoleByCodeUseCase findRoleByCode;
private final FindRolesUseCase findRoles;
private final UpdateRoleUseCase updateRole;
private final GenerateDefaultRoleUseCase generateDefaultRole;
private final DeleteRoleUseCase deleteRole;
private final DeleteAccessFromRolesUseCase deleteAccessFromRoles;
private final ForceFindRoleByIdUseCase forceFindRoleByIdUseCase;
private final GenerateGodModAccessUseCase generateGodModAccessUseCase;
private final GenerateManagerRoleUseCase generateManagerRoleUseCase;
public RoleConfig(RoleRepository roleRepository, RoleIdGenerator> roleIdGenerator, GetServicePreferenceUseCase getSettings, RoleAccessRepository roleAccessRepository, EventDispatcher eventDispatcher, GenerateGodModAccessUseCase generateGodModAccessUseCase) {
this.generateGodModAccessUseCase = generateGodModAccessUseCase;
this.createRole = new CreateRoleUseCase(roleRepository, roleIdGenerator, roleAccessRepository);
this.findRoleById = new FindRoleByIdUseCase(roleRepository);
this.findRoleByCode = new FindRoleByCodeUseCase(roleRepository);
this.findRoles = new FindRolesUseCase(roleRepository);
this.updateRole = new UpdateRoleUseCase(roleRepository, roleAccessRepository);
this.generateDefaultRole = new GenerateDefaultRoleUseCase(findRoleByCode, updateRole, createRole, getSettings, generateGodModAccessUseCase);
this.generateManagerRoleUseCase = new GenerateManagerRoleUseCase(findRoleByCode, createRole, generateGodModAccessUseCase);
this.deleteRole = new DeleteRoleUseCase(roleRepository);
this.deleteAccessFromRoles = new DeleteAccessFromRolesUseCase(roleRepository);
this.forceFindRoleByIdUseCase = new ForceFindRoleByIdUseCase(roleRepository);
eventDispatcher.registerHandler(RoleAccessDeletedEvent.class, new RoleAccessDeletedHandler(deleteAccessFromRoles));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy