diff --git a/src/main/java/com/springboot/ratelimiter/user/User.java b/src/main/java/com/springboot/ratelimiter/user/User.java index ca80cba..8d2e09c 100644 --- a/src/main/java/com/springboot/ratelimiter/user/User.java +++ b/src/main/java/com/springboot/ratelimiter/user/User.java @@ -4,6 +4,10 @@ import lombok.*; import lombok.experimental.SuperBuilder; +/** + * Domain Model class named {@link User} representing a User, extending from BaseDomainModel. + * Includes fields for id, name, and email. + */ @Getter @Setter @SuperBuilder diff --git a/src/main/java/com/springboot/ratelimiter/user/mapper/CreateUserRequestToUserEntityMapper.java b/src/main/java/com/springboot/ratelimiter/user/mapper/CreateUserRequestToUserEntityMapper.java index fcd7408..a4c9606 100644 --- a/src/main/java/com/springboot/ratelimiter/user/mapper/CreateUserRequestToUserEntityMapper.java +++ b/src/main/java/com/springboot/ratelimiter/user/mapper/CreateUserRequestToUserEntityMapper.java @@ -6,12 +6,27 @@ import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; +/** + * Mapper interface named {@link CreateUserRequestToUserEntityMapper} for converting {@link CreateUserRequest} to {@link UserEntity}. + * Extends BaseMapper for common mapping functionalities. + */ @Mapper public interface CreateUserRequestToUserEntityMapper extends BaseMapper { + /** + * Maps a CreateUserRequest object to a UserEntity object. + * + * @param createUserRequest the CreateUserRequest object to map + * @return the corresponding UserEntity object + */ @Override UserEntity map(CreateUserRequest createUserRequest); + /** + * Initializes the mapper instance using MapStruct's Mappers.getMapper() method. + * + * @return the initialized CreateUserRequestToUserEntityMapper instance + */ static CreateUserRequestToUserEntityMapper initialize() { return Mappers.getMapper(CreateUserRequestToUserEntityMapper.class); } diff --git a/src/main/java/com/springboot/ratelimiter/user/mapper/ListUserEntityToListUserMapper.java b/src/main/java/com/springboot/ratelimiter/user/mapper/ListUserEntityToListUserMapper.java index f9cd2c9..9a28c58 100644 --- a/src/main/java/com/springboot/ratelimiter/user/mapper/ListUserEntityToListUserMapper.java +++ b/src/main/java/com/springboot/ratelimiter/user/mapper/ListUserEntityToListUserMapper.java @@ -8,11 +8,20 @@ import java.util.List; import java.util.stream.Collectors; +/** + * Mapper interface named {@link ListUserEntityToListUserMapper} for converting a List of UserEntity objects to a List of User objects. + */ @Mapper public interface ListUserEntityToListUserMapper { UserEntityToUserMapper userEntityToUserMapper = Mappers.getMapper(UserEntityToUserMapper.class); + /** + * Converts a List of UserEntity objects to a List of User objects. + * + * @param userEntities the List of UserEntity objects to map + * @return the corresponding List of User objects + */ default List toUserList(List userEntities) { if (userEntities == null) { @@ -25,7 +34,11 @@ default List toUserList(List userEntities) { } - + /** + * Initializes the mapper instance using MapStruct's Mappers.getMapper() method. + * + * @return the initialized ListUserEntityToListUserMapper instance + */ static ListUserEntityToListUserMapper initialize() { return Mappers.getMapper(ListUserEntityToListUserMapper.class); } diff --git a/src/main/java/com/springboot/ratelimiter/user/mapper/UpdateUserRequestToUserEntityMapper.java b/src/main/java/com/springboot/ratelimiter/user/mapper/UpdateUserRequestToUserEntityMapper.java index da0ad9b..9c01a62 100644 --- a/src/main/java/com/springboot/ratelimiter/user/mapper/UpdateUserRequestToUserEntityMapper.java +++ b/src/main/java/com/springboot/ratelimiter/user/mapper/UpdateUserRequestToUserEntityMapper.java @@ -2,10 +2,22 @@ import com.springboot.ratelimiter.user.model.UserEntity; import com.springboot.ratelimiter.user.payload.request.UpdateUserRequest; +import lombok.experimental.UtilityClass; +/** + * Utility class named {@link UpdateUserRequestToUserEntityMapper} for mapping UpdateUserRequest to UserEntity for update operations. + */ +@UtilityClass public class UpdateUserRequestToUserEntityMapper { - public static UserEntity mapForUpdate(UserEntity userEntity, final UpdateUserRequest updateUserRequest) { + /** + * Maps fields from UpdateUserRequest to an existing UserEntity for update. + * + * @param userEntity the existing UserEntity to update + * @param updateUserRequest the UpdateUserRequest containing new data + * @return the updated UserEntity with fields from UpdateUserRequest + */ + public UserEntity mapForUpdate(UserEntity userEntity, final UpdateUserRequest updateUserRequest) { userEntity.setName(updateUserRequest.getName()); userEntity.setEmail(updateUserRequest.getEmail()); return userEntity; diff --git a/src/main/java/com/springboot/ratelimiter/user/mapper/UserEntityToUserMapper.java b/src/main/java/com/springboot/ratelimiter/user/mapper/UserEntityToUserMapper.java index fa79cdb..20892bb 100644 --- a/src/main/java/com/springboot/ratelimiter/user/mapper/UserEntityToUserMapper.java +++ b/src/main/java/com/springboot/ratelimiter/user/mapper/UserEntityToUserMapper.java @@ -6,13 +6,27 @@ import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; +/** + * Mapper interface named {@link UserEntityToUserMapper} for converting UserEntity to User. + * Extends BaseMapper for common mapping functionalities. + */ @Mapper public interface UserEntityToUserMapper extends BaseMapper { + /** + * Maps a UserEntity object to a User object. + * + * @param source the UserEntity object to map + * @return the corresponding User object + */ @Override User map(UserEntity source); - + /** + * Initializes the mapper instance using MapStruct's Mappers.getMapper() method. + * + * @return the initialized UserEntityToUserMapper instance + */ static UserEntityToUserMapper initialize() { return Mappers.getMapper(UserEntityToUserMapper.class); } diff --git a/src/main/java/com/springboot/ratelimiter/user/mapper/UserToUserResponseMapper.java b/src/main/java/com/springboot/ratelimiter/user/mapper/UserToUserResponseMapper.java index 195a200..b2ccd3e 100644 --- a/src/main/java/com/springboot/ratelimiter/user/mapper/UserToUserResponseMapper.java +++ b/src/main/java/com/springboot/ratelimiter/user/mapper/UserToUserResponseMapper.java @@ -6,12 +6,27 @@ import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; +/** + * Mapper interface named {@link UserToUserResponseMapper} for converting User to UserResponse. + * Extends BaseMapper for common mapping functionalities. + */ @Mapper public interface UserToUserResponseMapper extends BaseMapper { + /** + * Maps a User object to a UserResponse object. + * + * @param source the User object to map + * @return the corresponding UserResponse object + */ @Override UserResponse map(User source); + /** + * Initializes the mapper instance using MapStruct's Mappers.getMapper() method. + * + * @return the initialized UserToUserResponseMapper instance + */ static UserToUserResponseMapper initialize() { return Mappers.getMapper(UserToUserResponseMapper.class); } diff --git a/src/main/java/com/springboot/ratelimiter/user/model/UserEntity.java b/src/main/java/com/springboot/ratelimiter/user/model/UserEntity.java index 6eccf93..6ba1bcf 100644 --- a/src/main/java/com/springboot/ratelimiter/user/model/UserEntity.java +++ b/src/main/java/com/springboot/ratelimiter/user/model/UserEntity.java @@ -5,6 +5,10 @@ import lombok.*; import lombok.experimental.SuperBuilder; +/** + * Entity class named {@link UserEntity} representing a User, mapped to the "USERS" table. + * Includes fields for id, name, and email, with UUID generation for the id. + */ @Getter @Setter @EqualsAndHashCode(callSuper = true) diff --git a/src/main/java/com/springboot/ratelimiter/user/payload/request/CreateUserRequest.java b/src/main/java/com/springboot/ratelimiter/user/payload/request/CreateUserRequest.java index 84fa08d..6fd9b1c 100644 --- a/src/main/java/com/springboot/ratelimiter/user/payload/request/CreateUserRequest.java +++ b/src/main/java/com/springboot/ratelimiter/user/payload/request/CreateUserRequest.java @@ -4,6 +4,9 @@ import jakarta.validation.constraints.NotNull; import lombok.*; +/** + * DTO named {@link CreateUserRequest} for creating a new user, including name and email fields with validation. + */ @Getter @Setter @NoArgsConstructor diff --git a/src/main/java/com/springboot/ratelimiter/user/payload/request/UpdateUserRequest.java b/src/main/java/com/springboot/ratelimiter/user/payload/request/UpdateUserRequest.java index cccf25b..413253b 100644 --- a/src/main/java/com/springboot/ratelimiter/user/payload/request/UpdateUserRequest.java +++ b/src/main/java/com/springboot/ratelimiter/user/payload/request/UpdateUserRequest.java @@ -4,6 +4,9 @@ import jakarta.validation.constraints.NotNull; import lombok.*; +/** + * DTO named {@link UpdateUserRequest} for updating an existing user, including name and email fields with validation. + */ @Getter @Setter @NoArgsConstructor diff --git a/src/main/java/com/springboot/ratelimiter/user/payload/request/UserPagingRequest.java b/src/main/java/com/springboot/ratelimiter/user/payload/request/UserPagingRequest.java index d1070cb..ef05389 100644 --- a/src/main/java/com/springboot/ratelimiter/user/payload/request/UserPagingRequest.java +++ b/src/main/java/com/springboot/ratelimiter/user/payload/request/UserPagingRequest.java @@ -6,6 +6,9 @@ import lombok.Setter; import lombok.experimental.SuperBuilder; +/** + * DTO named {@link UserPagingRequest} for paginating user data, extending from CustomPagingRequest. + */ @Getter @Setter @SuperBuilder diff --git a/src/main/java/com/springboot/ratelimiter/user/payload/response/UserResponse.java b/src/main/java/com/springboot/ratelimiter/user/payload/response/UserResponse.java index e53024d..94c61a3 100644 --- a/src/main/java/com/springboot/ratelimiter/user/payload/response/UserResponse.java +++ b/src/main/java/com/springboot/ratelimiter/user/payload/response/UserResponse.java @@ -2,6 +2,9 @@ import lombok.*; +/** + * DTO named {@link UserResponse} for user response, including id, name, and email fields. + */ @Getter @Builder @NoArgsConstructor diff --git a/src/main/java/com/springboot/ratelimiter/user/repository/UserRepository.java b/src/main/java/com/springboot/ratelimiter/user/repository/UserRepository.java index 3100426..2349a42 100644 --- a/src/main/java/com/springboot/ratelimiter/user/repository/UserRepository.java +++ b/src/main/java/com/springboot/ratelimiter/user/repository/UserRepository.java @@ -3,7 +3,16 @@ import com.springboot.ratelimiter.user.model.UserEntity; import org.springframework.data.jpa.repository.JpaRepository; +/** + * Repository interface named {@link UserRepository} for managing UserEntity entities. + */ public interface UserRepository extends JpaRepository { + /** + * Checks if a user exists by their email address. + * + * @param email the email address to check + * @return true if a user with the given email address exists, false otherwise + */ boolean existsByEmail(String email); }