Class RoleService

java.lang.Object
hu.rts.mike.example.dev.crm.service.RoleService

@Service public class RoleService extends Object
  • Field Details

    • roleRepository

      private final RoleRepository roleRepository
    • authInfoRepository

      private final AuthInfoRepository authInfoRepository
    • mapper

      private final org.modelmapper.ModelMapper mapper
  • Constructor Details

  • Method Details

    • findAll

      @RolesAllowed("READ_ROLE") public List<RoleDto> findAll()
      Returns the list of Roles as DTOs.
      Returns:
      The list of DTOs.
    • findAllForGrid

      @RolesAllowed("READ_ROLE") public org.springframework.data.domain.Page<RoleListDto> findAllForGrid(List<Filter<?>> filters, String searchBarValue, org.springframework.data.domain.Pageable pageable)
      Provides role information for the grid of RoleListView.
      Parameters:
      filters - The filters to apply on role data available.
      pageable - The page to be filled with role data.
      Returns:
      A page of filtered role data.
    • delete

      @RolesAllowed("DELETE_ROLE") public long delete(String name)
      Deletes a role if it is not in use by any users.
      Parameters:
      name - The name of the role to be deleted.
      Returns:
      The number of roles deleted (0 or 1).
      Throws:
      RoleInUseException - Thrown if at least one user use this role.
    • delete

      @RolesAllowed("DELETE_ROLE") public void delete(Set<String> names)
    • safeSave

      @RolesAllowed({"CREATE_ROLE","UPDATE_ROLE"}) public RoleListDto safeSave(RoleListDto roleListDto, boolean isNew)
      Creates a new role or modifies an existing one. The name of existing roles cannot be modified.
      Parameters:
      roleListDto - DTO containing all role data including privileges.
      isNew - True if a new Role should be created instead of modifiying an existing one.
      Throws:
      RoleExistsException - If a new Role should be created, but another Role with the same name already exists.
    • findById

      @RolesAllowed("READ_ROLE") public RoleListDto findById(String id)