Class AdminService

java.lang.Object
callofproject.dev.authentication.service.AdminService

@Service @Lazy public class AdminService extends Object
Service class for admin-related operations. It implements the IAdminService interface.
  • 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 dependency
      kafkaProducer - KafkaProducer dependency
      authenticationProvider - AuthenticationProvider dependency
      userMapper - 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

      public callofproject.dev.data.common.clas.ResponseMessage<Boolean> removeUser(String username)
      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 page
      word - 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 page
      word - 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

      public Object authenticate(AuthenticationRequest request)
      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.