Class RoleService
java.lang.Object
hu.rts.mike.example.dev.crm.service.RoleService
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AuthInfoRepositoryprivate final org.modelmapper.ModelMapperprivate final RoleRepository -
Constructor Summary
ConstructorsConstructorDescriptionRoleService(RoleRepository roleRepository, AuthInfoRepository authInfoRepository, org.modelmapper.ModelMapper mapper) -
Method Summary
Modifier and TypeMethodDescriptionlongDeletes a role if it is not in use by any users.voidfindAll()Returns the list of Roles as DTOs.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.safeSave(RoleListDto roleListDto, boolean isNew) Creates a new role or modifies an existing one.
-
Field Details
-
roleRepository
-
authInfoRepository
-
mapper
private final org.modelmapper.ModelMapper mapper
-
-
Constructor Details
-
RoleService
public RoleService(RoleRepository roleRepository, AuthInfoRepository authInfoRepository, org.modelmapper.ModelMapper mapper)
-
-
Method Details
-
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
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
-
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
-