Class UserDto
java.lang.Object
me.josephsf.jobportaljosephsfeir.dto.UserDto
Data Transfer Object for user information.
This class encapsulates user account information in the Job Portal system, excluding sensitive information like passwords. It is primarily used for transferring user data between the service layer and the presentation layer, particularly when displaying user profiles or lists of users.
The class includes validation constraints to ensure data integrity when updating user information:
- Username must be between 3 and 20 characters
- Email must be valid and not exceed 50 characters
The DTO also tracks the roles assigned to the user, which determine their access levels and permissions within the system.
- Since:
- 2025-05-14
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the creation timestamp.getEmail()Gets the email address.getId()Gets the MongoDB document ID.getRoles()Gets the set of roles.Gets the last update timestamp.Gets the username.voidsetCreatedAt(LocalDateTime createdAt) Sets the creation timestamp.voidSets the email address.voidSets the MongoDB document ID.voidSets the set of roles.voidsetUpdatedAt(LocalDateTime updatedAt) Sets the last update timestamp.voidsetUsername(String username) Sets the username.
-
Constructor Details
-
UserDto
public UserDto()Default constructor for deserialization. -
UserDto
Constructs a new UserDto with essential fields.- Parameters:
id- The MongoDB document IDusername- The usernameemail- The email addressroles- The set of roles assigned to the user
-
-
Method Details
-
getId
Gets the MongoDB document ID.- Returns:
- The document ID
-
setId
Sets the MongoDB document ID.- Parameters:
id- The document ID to set
-
getUsername
Gets the username.- Returns:
- The username
-
setUsername
Sets the username.- Parameters:
username- The username to set
-
getEmail
Gets the email address.- Returns:
- The email address
-
setEmail
Sets the email address.- Parameters:
email- The email address to set
-
getRoles
Gets the set of roles.- Returns:
- The set of roles
-
setRoles
Sets the set of roles.- Parameters:
roles- The set of roles to set
-
getCreatedAt
Gets the creation timestamp.- Returns:
- The creation timestamp
-
setCreatedAt
Sets the creation timestamp.- Parameters:
createdAt- The creation timestamp to set
-
getUpdatedAt
Gets the last update timestamp.- Returns:
- The last update timestamp
-
setUpdatedAt
Sets the last update timestamp.- Parameters:
updatedAt- The last update timestamp to set
-