Class UserService
java.lang.Object
hu.rts.mike.example.dev.crm.service.UserService
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AuthInfoRepositoryprivate final org.modelmapper.ModelMapperprivate final TokenCacheprivate final UserInfoRepository -
Constructor Summary
ConstructorsConstructorDescriptionUserService(AuthInfoRepository authInfoRepository, UserInfoRepository userInfoRepository, org.modelmapper.ModelMapper mapper, TokenCache tokenCache) -
Method Summary
Modifier and TypeMethodDescriptionvoidblockUser(UserListDto userListDto) Blocks a user (prevents login)voidblockUsers(Set<UUID> ids) voidenableUser(UUID id) Enables a user (allows user to log in)voidenableUsers(Set<UUID> ids) org.springframework.data.domain.Page<UserListDto>findAllForGrid(List<Filter<?>> filters, String searchBarValue, org.springframework.data.domain.Pageable pageable) Provides user information for the grid of UserListView.private StringgetErrorMessage(UserListDto userListDto) private booleanisLastCreateUser(UserListDto userListDto) Is the specified user the last one who has CREATE_USER privilege in the system?safeSave(UserListDto userListDto) Blocks user only if it existed, was allowed to log in and there is at least one more user who has CREATE_USER privilege.
-
Field Details
-
authInfoRepository
-
userInfoRepository
-
mapper
private final org.modelmapper.ModelMapper mapper -
tokenCache
-
-
Constructor Details
-
UserService
public UserService(AuthInfoRepository authInfoRepository, UserInfoRepository userInfoRepository, org.modelmapper.ModelMapper mapper, TokenCache tokenCache)
-
-
Method Details
-
getErrorMessage
-
blockUser
Blocks a user (prevents login)- Parameters:
userListDto- The user to block
-
blockUsers
-
enableUser
Enables a user (allows user to log in)- Parameters:
id- The ID of the user to enable
-
enableUsers
-
isLastCreateUser
Is the specified user the last one who has CREATE_USER privilege in the system?- Parameters:
userListDto- The user we want to block- Returns:
- True if he/she is the last user with CREATE_USER privilege thus cannot be blocked.
-
safeSave
Blocks user only if it existed, was allowed to log in and there is at least one more user who has CREATE_USER privilege.- Parameters:
userListDto- The user to be saved.- Throws:
LastUserWhoCanCreateUsersException- If it was the last user with CREATE_USER privilege thus cannot be blocked.
-
findAllForGrid
@RolesAllowed("READ_USER") public org.springframework.data.domain.Page<UserListDto> findAllForGrid(List<Filter<?>> filters, String searchBarValue, org.springframework.data.domain.Pageable pageable) Provides user information for the grid of UserListView.- Parameters:
filters- The filters to apply on user data available.pageable- The page to be filled with user data.- Returns:
- A page of filtered user data.
-
findById
-