Class AdminService
java.lang.Object
callofproject.dev.authentication.service.AdminService
Service class for admin-related operations.
It implements the IAdminService interface.
-
Constructor Summary
ConstructorsConstructorDescriptionAdminService(callofproject.dev.repository.authentication.dal.UserManagementServiceHelper managementServiceHelper, KafkaProducer kafkaProducer, org.springframework.security.authentication.AuthenticationProvider authenticationProvider, IUserMapper userMapper) Constructor for AdminService class. -
Method Summary
Modifier and TypeMethodDescriptionauthenticate(AuthenticationRequest request) Authenticates a user based on their username and password.longFind total user count.callofproject.dev.data.common.clas.MultipleResponseMessagePageable<UsersShowingAdminDTO>findAllUsersPageable(int page) Find all users pageablelongfindNewUsersLastNday(long day) Find new users last n day.callofproject.dev.data.common.clas.MultipleResponseMessagePageable<UsersShowingAdminDTO>findUsersByUsernameContainsIgnoreCase(int page, String word) Find Users with given word.callofproject.dev.data.common.clas.MultipleResponseMessagePageable<UsersShowingAdminDTO>findUsersByUsernameNotContainsIgnoreCase(int page, String word) Find Users with given word.callofproject.dev.data.common.clas.ResponseMessage<Boolean>removeUser(String username) Remove user with given usernamecallofproject.dev.data.common.clas.ResponseMessage<UserShowingAdminDTO>updateUser(UserUpdateDTOAdmin userUpdateDTO) Update user with given UserUpdateDTOAdmin classcallofproject.dev.data.common.clas.ResponseMessage<UserShowingAdminDTO>updateUserCallbackAdmin(UserUpdateDTOAdmin userUpdateDTO) Updates user information based on the provided UserUpdateDTOAdmin data.
-
Constructor Details
-
AdminService
public AdminService(callofproject.dev.repository.authentication.dal.UserManagementServiceHelper managementServiceHelper, KafkaProducer kafkaProducer, org.springframework.security.authentication.AuthenticationProvider authenticationProvider, IUserMapper userMapper) Constructor for AdminService class.- Parameters:
managementServiceHelper- UserManagementServiceHelper dependencykafkaProducer- KafkaProducer dependencyauthenticationProvider- AuthenticationProvider dependencyuserMapper- IUserMapper dependency
-
-
Method Details
-
findAllUsersPageable
public callofproject.dev.data.common.clas.MultipleResponseMessagePageable<UsersShowingAdminDTO> findAllUsersPageable(int page) Find all users pageable- Parameters:
page- represent the page- Returns:
- the UsersShowingAdminDTO
-
removeUser
Remove user with given username- Parameters:
username- represent the username- Returns:
- boolean value.
-
findUsersByUsernameContainsIgnoreCase
public callofproject.dev.data.common.clas.MultipleResponseMessagePageable<UsersShowingAdminDTO> findUsersByUsernameContainsIgnoreCase(int page, String word) Find Users with given word. If username contains the word, return it.- Parameters:
page- represent the pageword- represent the part of username- Returns:
- UsersShowingAdminDTO
-
findUsersByUsernameNotContainsIgnoreCase
public callofproject.dev.data.common.clas.MultipleResponseMessagePageable<UsersShowingAdminDTO> findUsersByUsernameNotContainsIgnoreCase(int page, String word) Find Users with given word. If username not contains the word, return it.- Parameters:
page- represent the pageword- represent the part of username- Returns:
- UsersShowingAdminDTO
-
updateUser
public callofproject.dev.data.common.clas.ResponseMessage<UserShowingAdminDTO> updateUser(UserUpdateDTOAdmin userUpdateDTO) Update user with given UserUpdateDTOAdmin class- Parameters:
userUpdateDTO- represent the updating information- Returns:
- UserShowingAdminDTO class.
-
findAllUserCount
public long findAllUserCount()Find total user count.- Returns:
- the total user count
-
findNewUsersLastNday
public long findNewUsersLastNday(long day) Find new users last n day.- Parameters:
day- represent the day- Returns:
- new user count.
-
updateUserCallbackAdmin
public callofproject.dev.data.common.clas.ResponseMessage<UserShowingAdminDTO> updateUserCallbackAdmin(UserUpdateDTOAdmin userUpdateDTO) Updates user information based on the provided UserUpdateDTOAdmin data.- Parameters:
userUpdateDTO- The DTO containing user's updated information.- Returns:
- A ResponseMessage containing the updated UserShowingAdminDTO.
- Throws:
callofproject.dev.library.exception.service.DataServiceException- if the user is not found or cannot be edited due to role restrictions.
-
authenticate
Authenticates a user based on their username and password.- Parameters:
request- The authentication request containing the user's credentials.- Returns:
- An AuthenticationResponse containing the JWT token and other authentication details.
- Throws:
callofproject.dev.library.exception.service.DataServiceException- if the user is not an admin or if authentication fails.
-