Interface UserPermission

All Known Implementing Classes:
UserPermissionProvider

public sealed interface UserPermission permits UserPermissionProvider
User permission interface to manage user permissions.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addPermission(int executorId, int userId, String permission, long time)
    Adds a specific permission to a user with an optional expiration time.
    void
    clearPermission(int userId)
    Clears all permissions associated with a specific user.
    boolean
    existsPermission(int userId, String permission)
    Checks whether a specific permission exists for a given user.
    getCreatedAt(int userId, String permission)
    Retrieves the creation timestamp of a specific permission for a given user.
    int
    getCreatedBy(int userId, String permission)
    Retrieves the identifier of the user who created the specified permission for a given user.
    getExpiredDate(int userId, String permission)
    Retrieves the expiration date of a specific permission for a given user.
    long
    getExpiredTime(int userId, String permission)
    Retrieves the expiration time of a specific permission for a given user.
    getModifiedAt(int userId, String permission)
    Retrieves the timestamp indicating the last modification time of a specific permission associated with a given user.
    int
    getModifiedBy(int userId, String permission)
    Retrieves the identifier of the executor who last modified a specific permission associated with a user.
    getPermissions(int userId)
    Retrieves a list of permissions associated with a specific user.
    boolean
    isExpired(int userId, String permission)
    Checks if a specific permission for a given user has expired.
    void
    Loads all expired permissions for the specified user and performs operations related to the expired permissions.
    void
    removePermission(int userId, String permission)
    Removes a specific permission from a user.
    setExpiredTime(int executorId, int userId, String permission, long time)
    Sets the expiration time for a specific permission associated with a user.
  • Method Details

    • existsPermission

      boolean existsPermission(int userId, String permission)
      Checks whether a specific permission exists for a given user.
      Parameters:
      userId - The unique identifier of the user.
      permission - The permission to check for the user.
      Returns:
      true if the permission exists for the user, otherwise false.
    • addPermission

      void addPermission(int executorId, int userId, String permission, long time)
      Adds a specific permission to a user with an optional expiration time.
      Parameters:
      executorId - The unique identifier for the log entry of the operation.
      userId - The unique identifier of the user to whom the permission will be added.
      permission - The permission string to be added to the user.
      time - The expiration time for the permission in milliseconds. Use -1 for no expiration.
    • removePermission

      void removePermission(int userId, String permission)
      Removes a specific permission from a user.
      Parameters:
      userId - The unique identifier of the user from whom the permission will be removed.
      permission - The permission string to be removed from the user.
    • clearPermission

      void clearPermission(int userId)
      Clears all permissions associated with a specific user.
      Parameters:
      userId - The unique identifier of the user whose permissions will be cleared.
    • getPermissions

      List<String> getPermissions(int userId)
      Retrieves a list of permissions associated with a specific user.
      Parameters:
      userId - The unique identifier of the user whose permissions are being retrieved.
      Returns:
      A list of permission strings associated with the specified user.
    • getExpiredTime

      long getExpiredTime(int userId, String permission)
      Retrieves the expiration time of a specific permission for a given user.
      Parameters:
      userId - The unique identifier of the user.
      permission - The permission for which the expiration time is being retrieved.
      Returns:
      The expiration time in milliseconds since the epoch for the specified permission and user. Returns -1 if the permission has no expiration time.
    • getExpiredDate

      String getExpiredDate(int userId, String permission)
      Retrieves the expiration date of a specific permission for a given user. The expiration date is returned as a formatted string representation.
      Parameters:
      userId - The unique identifier of the user.
      permission - The permission for which the expiration date is being retrieved.
      Returns:
      A string representation of the expiration date for the specified user and permission. Returns an empty string if the permission has no expiration date.
    • setExpiredTime

      String setExpiredTime(int executorId, int userId, String permission, long time)
      Sets the expiration time for a specific permission associated with a user. Updates the expiration to the specified time in milliseconds.
      Parameters:
      executorId - The unique identifier for the log entry of the operation.
      userId - The unique identifier of the user.
      permission - The permission for which the expiration time will be set.
      time - The expiration time in milliseconds since the epoch. Use -1 for no expiration.
      Returns:
      A string indicating the status of the operation, such as success or an error message.
    • isExpired

      boolean isExpired(int userId, String permission)
      Checks if a specific permission for a given user has expired.
      Parameters:
      userId - The unique identifier of the user.
      permission - The permission whose expiration status is being checked.
      Returns:
      true if the permission has expired, otherwise false.
    • getCreatedBy

      int getCreatedBy(int userId, String permission)
      Retrieves the identifier of the user who created the specified permission for a given user.
      Parameters:
      userId - The unique identifier of the user for whom the permission was created.
      permission - The permission whose creator's identifier is to be retrieved.
      Returns:
      The unique identifier of the user who created the specified permission.
    • getCreatedAt

      Timestamp getCreatedAt(int userId, String permission)
      Retrieves the creation timestamp of a specific permission for a given user.
      Parameters:
      userId - The unique identifier of the user.
      permission - The permission for which the creation timestamp is being retrieved.
      Returns:
      The timestamp indicating when the specified permission was created for the user.
    • getModifiedBy

      int getModifiedBy(int userId, String permission)
      Retrieves the identifier of the executor who last modified a specific permission associated with a user.
      Parameters:
      userId - The unique identifier of the user whose permission modification details are being retrieved.
      permission - The permission for which the modification details are being retrieved.
      Returns:
      The unique identifier of the executor who last modified the specified permission for the given user.
    • getModifiedAt

      Timestamp getModifiedAt(int userId, String permission)
      Retrieves the timestamp indicating the last modification time of a specific permission associated with a given user.
      Parameters:
      userId - The unique identifier of the user whose permission modification timestamp is needed.
      permission - The permission for which the last modification time will be retrieved.
      Returns:
      The timestamp representing the last modification time of the specified permission for the given user. Returns null if no modification timestamp is found.
    • loadExpired

      void loadExpired(User user)
      Loads all expired permissions for the specified user and performs operations related to the expired permissions.
      Parameters:
      user - The user whose expired permissions need to be loaded. This is the user object associated with the permissions.