diff --git a/src/main/java/com/project/parkinglot/ParkinglotApplication.java b/src/main/java/com/project/parkinglot/ParkinglotApplication.java index ba0fac1..64fac5a 100644 --- a/src/main/java/com/project/parkinglot/ParkinglotApplication.java +++ b/src/main/java/com/project/parkinglot/ParkinglotApplication.java @@ -3,9 +3,17 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +/** + * Main class named {@link ParkinglotApplication} to start the Parking Lot application. + */ @SpringBootApplication public class ParkinglotApplication { + /** + * Main method to start the Spring Boot application. + * + * @param args the command line arguments + */ public static void main(String[] args) { SpringApplication.run(ParkinglotApplication.class, args); } diff --git a/src/main/java/com/project/parkinglot/common/model/entity/BaseEntity.java b/src/main/java/com/project/parkinglot/common/model/entity/BaseEntity.java index 12d618a..4573bc3 100644 --- a/src/main/java/com/project/parkinglot/common/model/entity/BaseEntity.java +++ b/src/main/java/com/project/parkinglot/common/model/entity/BaseEntity.java @@ -15,6 +15,11 @@ import java.time.LocalDateTime; +/** + * Base class named {@link BaseEntity} for all entities in the application. It provides common fields + * such as createdUser, createdAt, updatedUser, and updatedAt along with + * prePersist and preUpdate hooks to manage these fields automatically. + */ @Getter @Setter @SuperBuilder diff --git a/src/main/java/com/project/parkinglot/config/OpenApiConfig.java b/src/main/java/com/project/parkinglot/config/OpenApiConfig.java index 1c225f5..67fb165 100644 --- a/src/main/java/com/project/parkinglot/config/OpenApiConfig.java +++ b/src/main/java/com/project/parkinglot/config/OpenApiConfig.java @@ -7,6 +7,9 @@ import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.security.SecurityScheme; +/** + * Configuration class named {@link OpenApiConfig} for OpenAPI documentation. + */ @OpenAPIDefinition( info = @Info( contact = @Contact( diff --git a/src/main/java/com/project/parkinglot/config/SecurityConfig.java b/src/main/java/com/project/parkinglot/config/SecurityConfig.java index a3cdd92..f0b7510 100644 --- a/src/main/java/com/project/parkinglot/config/SecurityConfig.java +++ b/src/main/java/com/project/parkinglot/config/SecurityConfig.java @@ -25,6 +25,9 @@ import java.util.List; +/** + * Configuration class named {@link SecurityConfig} for security settings. + */ @Configuration @EnableWebSecurity @EnableMethodSecurity diff --git a/src/main/java/com/project/parkinglot/controller/AuthController.java b/src/main/java/com/project/parkinglot/controller/AuthController.java index 8400766..36b8b54 100644 --- a/src/main/java/com/project/parkinglot/controller/AuthController.java +++ b/src/main/java/com/project/parkinglot/controller/AuthController.java @@ -17,6 +17,9 @@ import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; +/** + * Controller class named {@link AuthController} for authentication operations. + */ @RestController @RequestMapping("/api/v1/auth") @RequiredArgsConstructor @@ -25,6 +28,12 @@ public class AuthController { private final AuthService authService; + /** + * Registers a new user. + * + * @param request The SignupRequest object containing user details. + * @return A CustomResponse containing a success message. + */ @PostMapping("/register") @ResponseStatus(HttpStatus.CREATED) @Operation(summary = "Register a new user", description = "Registers a new user and returns a success message.", @@ -37,6 +46,12 @@ public CustomResponse register(@RequestBody SignupRequest request) { return CustomResponse.created(authService.register(request)); } + /** + * Logs in a user and returns JWT tokens. + * + * @param request The LoginRequest object containing user credentials. + * @return A CustomResponse containing JWT tokens. + */ @PostMapping("/login") @Operation(summary = "Login user", description = "Logs in a user and returns JWT tokens.", responses = { @@ -48,6 +63,12 @@ public CustomResponse login(@RequestBody LoginRequest request) { return CustomResponse.ok(authService.login(request)); } + /** + * Refreshes the JWT authentication token using a refresh token. + * + * @param request The TokenRefreshRequest object containing the refresh token. + * @return A CustomResponse containing the refreshed token. + */ @PostMapping("/refreshtoken") @Operation(summary = "Refresh token", description = "Refreshes the JWT authentication token using a refresh token.", responses = { @@ -59,6 +80,12 @@ public CustomResponse refreshToken(@RequestBody TokenRefre return CustomResponse.ok(authService.refreshToken(request)); } + /** + * Logs out a user by invalidating the authentication token. + * + * @param token The JWT token to invalidate. + * @return A CustomResponse containing a success message. + */ @PostMapping("/logout") @Operation(summary = "Logout user", description = "Logs out a user by invalidating the authentication token.", responses = { diff --git a/src/main/java/com/project/parkinglot/controller/ParkController.java b/src/main/java/com/project/parkinglot/controller/ParkController.java index 89fb66f..65cf5d8 100644 --- a/src/main/java/com/project/parkinglot/controller/ParkController.java +++ b/src/main/java/com/project/parkinglot/controller/ParkController.java @@ -19,6 +19,9 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +/** + * Controller class named {@link ParkController} for park management operations. + */ @RestController @RequestMapping("/api/v1/parks") @RequiredArgsConstructor @@ -28,6 +31,13 @@ public class ParkController { private final ParkService parkService; + /** + * Allows a driver to check in to a park, recording the time and location. + * + * @param userId The ID of the user checking in. + * @param parkCheckInRequest The ParkCheckInRequest containing check-in details. + * @return A CustomResponse containing the check-in response. + */ @PostMapping("/userId/{userId}/check-in") @PreAuthorize("hasAuthority('ROLE_DRIVER')") @Operation(summary = "Check in to a park", @@ -44,6 +54,13 @@ public CustomResponse checkIn(@PathVariable @UUID final Str return CustomResponse.ok(parkCheckInResponse); } + /** + * Allows a driver to check out from a park, recording the departure time. + * + * @param userId The ID of the user checking out. + * @param parkCheckOutRequest The ParkCheckOutRequest containing check-out details. + * @return A CustomResponse containing the check-out response. + */ @PostMapping("/userId/{userId}/check-out") @PreAuthorize("hasAuthority('ROLE_DRIVER')") @Operation(summary = "Check out from a park", diff --git a/src/main/java/com/project/parkinglot/controller/ParkingAreaController.java b/src/main/java/com/project/parkinglot/controller/ParkingAreaController.java index a53a161..9406842 100644 --- a/src/main/java/com/project/parkinglot/controller/ParkingAreaController.java +++ b/src/main/java/com/project/parkinglot/controller/ParkingAreaController.java @@ -26,6 +26,9 @@ import java.time.LocalDate; +/** + * Controller class named {@link ParkingAreaController} for managing parking areas. + */ @RestController @RequestMapping("/api/v1/parking-area") @RequiredArgsConstructor @@ -38,6 +41,12 @@ public class ParkingAreaController { private final ParkingAreaDeleteService parkingAreaDeleteService; private final ParkingAreaGetService parkingAreaGetService; + /** + * Creates a new parking area with the specified details. + * + * @param parkingAreaCreateRequest The details of the parking area to be created. + * @return A CustomResponse indicating the success of the operation. + */ @PostMapping @PreAuthorize("hasAuthority('ROLE_ADMIN')") @Operation(summary = "Create a new parking area", @@ -57,6 +66,12 @@ public CustomResponse createParkingArea(@RequestBody @Valid final Parkin } + /** + * Retrieves details of a parking area by its ID. + * + * @param parkingAreaId The ID of the parking area. + * @return A CustomResponse containing the details of the parking area. + */ @GetMapping("/{parkingAreaId}") @PreAuthorize("hasAuthority('ROLE_ADMIN')") @Operation(summary = "Get a parking area by ID", @@ -74,6 +89,12 @@ public CustomResponse getParkingAreaById(@PathVariable("parkingArea } + /** + * Retrieves details of a parking area by its name. + * + * @param name The name of the parking area. + * @return A CustomResponse containing the details of the parking area. + */ @GetMapping("/name/{name}") @PreAuthorize("hasAuthority('ROLE_ADMIN')") @Operation(summary = "Get a parking area by name", @@ -91,6 +112,13 @@ public CustomResponse getParkingAreaByName(@PathVariable("name") @N } + /** + * Retrieves the daily income for a parking area on a specified date. + * + * @param date The date for which the income is to be retrieved. + * @param parkingAreaId The ID of the parking area. + * @return A CustomResponse containing the daily income for the parking area. + */ @GetMapping("/income") @PreAuthorize("hasAuthority('ROLE_ADMIN')") @Operation(summary = "Get daily income for a parking area", @@ -109,6 +137,12 @@ public CustomResponse getDailyIncome( return CustomResponse.ok(dailyIncome); } + /** + * Deletes a parking area by its ID. + * + * @param parkingAreaId The ID of the parking area to be deleted. + * @return A CustomResponse indicating the success of the operation. + */ @DeleteMapping("/{parkingAreaId}") @PreAuthorize("hasAuthority('ROLE_ADMIN')") @Operation(summary = "Delete a parking area by ID", @@ -126,6 +160,13 @@ public CustomResponse deleteParkingAreaById(@PathVariable("parkingAreaId } + /** + * Updates a parking area by its ID based on the provided data. + * + * @param parkingAreaId The ID of the parking area to be updated. + * @param parkingAreaUpdateRequest The updated details of the parking area. + * @return A CustomResponse indicating the success of the operation. + */ @PutMapping("/{parkingAreaId}") @PreAuthorize("hasAuthority('ROLE_ADMIN')") @Operation(summary = "Update a parking area by ID", diff --git a/src/main/java/com/project/parkinglot/controller/UserController.java b/src/main/java/com/project/parkinglot/controller/UserController.java index a0bb7ff..6daa74f 100644 --- a/src/main/java/com/project/parkinglot/controller/UserController.java +++ b/src/main/java/com/project/parkinglot/controller/UserController.java @@ -18,6 +18,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +/** + * Controller class named {@link UserController} for managing user information. + */ @RestController @RequestMapping("/api/v1/users") @RequiredArgsConstructor @@ -27,6 +30,12 @@ public class UserController { private final UserGetService userGetService; + /** + * Retrieves detailed information for a specific user by their ID. + * + * @param userId The ID of the user. + * @return A CustomResponse containing the user information. + */ @GetMapping("/user/{user-id}") @PreAuthorize("hasAuthority('ROLE_DRIVER')") @Operation(summary = "Get user information by ID", @@ -44,6 +53,12 @@ public CustomResponse getUserInformationById(@PathVariable("user-id") @UUI return CustomResponse.ok(user); } + /** + * Retrieves detailed information for a specific admin by their ID. + * + * @param adminId The ID of the admin. + * @return A CustomResponse containing the admin information. + */ @GetMapping("/admin/{admin-id}") @PreAuthorize("hasAuthority('ROLE_ADMIN')") @Operation(summary = "Get admin information by ID", diff --git a/src/main/java/com/project/parkinglot/controller/VehicleController.java b/src/main/java/com/project/parkinglot/controller/VehicleController.java index 0d0acbe..a8b473e 100644 --- a/src/main/java/com/project/parkinglot/controller/VehicleController.java +++ b/src/main/java/com/project/parkinglot/controller/VehicleController.java @@ -19,6 +19,9 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +/** + * Controller class named {@link VehicleController} for managing vehicles. + */ @RestController @RequiredArgsConstructor @RequestMapping("api/v1/vehicles") @@ -28,6 +31,13 @@ public class VehicleController { private final VehicleService vehicleService; + /** + * Assigns a vehicle based on the provided request to a specified user. + * + * @param userId The ID of the user to whom the vehicle is to be assigned. + * @param vehicleRequest The details of the vehicle to be assigned. + * @return A CustomResponse indicating the success of the operation. + */ @PostMapping("/assign/{user-id}") @PreAuthorize("hasAuthority('ROLE_DRIVER')") @Operation(summary = "Assign a vehicle to a user", @@ -48,6 +58,12 @@ public CustomResponse assignVehicleToUser( return CustomResponse.ok(vehicle.getLicensePlate()); } + /** + * Retrieves parking details for a vehicle using its license plate number. + * + * @param licensePlate The license plate number of the vehicle. + * @return A CustomResponse containing the parking details of the vehicle. + */ @GetMapping("/get-parking-detail/{licensePlate}") @PreAuthorize("hasAuthority('ROLE_DRIVER')") @Operation(summary = "Get parking details of a vehicle", diff --git a/src/main/java/com/project/parkinglot/exception/AlreadyException.java b/src/main/java/com/project/parkinglot/exception/AlreadyException.java index e974126..c8f6924 100644 --- a/src/main/java/com/project/parkinglot/exception/AlreadyException.java +++ b/src/main/java/com/project/parkinglot/exception/AlreadyException.java @@ -4,6 +4,10 @@ import java.io.Serial; +/** + * An abstract exception class named {@link AlreadyException} representing the scenario where an entity already exists. + * This exception should be extended by specific exception classes for different entities. + */ public abstract class AlreadyException extends RuntimeException { @Serial diff --git a/src/main/java/com/project/parkinglot/exception/GlobalExceptionHandler.java b/src/main/java/com/project/parkinglot/exception/GlobalExceptionHandler.java index 03873d4..788f48b 100644 --- a/src/main/java/com/project/parkinglot/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/project/parkinglot/exception/GlobalExceptionHandler.java @@ -27,10 +27,22 @@ import java.util.ArrayList; import java.util.List; +/** + * Global exception handler class named {@link GlobalExceptionHandler} for handling various exceptions across the application. + */ @ControllerAdvice @Slf4j public class GlobalExceptionHandler extends ResponseEntityExceptionHandler { + /** + * Handles HTTP media type not supported exception. + * + * @param ex The HttpMediaTypeNotSupportedException thrown + * @param headers The headers of the HTTP request + * @param status The status of the HTTP request + * @param request The HTTP request + * @return ResponseEntity with an error response + */ @Override protected ResponseEntity handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex, HttpHeaders headers, @@ -57,6 +69,15 @@ protected ResponseEntity handleHttpMediaTypeNotSupported(HttpMediaTypeNo return ResponseEntity.status(status).body(errorResponse); } + /** + * Handles HTTP message not readable exception. + * + * @param ex The HttpMessageNotReadableException thrown + * @param headers The headers of the HTTP request + * @param status The status of the HTTP request + * @param request The HTTP request + * @return ResponseEntity with an error response + */ @Override protected ResponseEntity handleHttpMessageNotReadable(HttpMessageNotReadableException ex, HttpHeaders headers, @@ -78,6 +99,15 @@ protected ResponseEntity handleHttpMessageNotReadable(HttpMessageNotRead return ResponseEntity.status(status).body(errorResponse); } + /** + * Handles method argument not valid exception. + * + * @param ex The MethodArgumentNotValidException thrown + * @param headers The headers of the HTTP request + * @param status The status of the HTTP request + * @param request The HTTP request + * @return ResponseEntity with an error response + */ @Override protected ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, @@ -102,6 +132,15 @@ protected ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotV } + /** + * Handles missing servlet request parameter exception. + * + * @param ex The MissingServletRequestParameterException thrown + * @param headers The headers of the HTTP request + * @param status The status of the HTTP request + * @param request The HTTP request + * @return ResponseEntity with an error response + */ @Override protected ResponseEntity handleMissingServletRequestParameter(MissingServletRequestParameterException ex, HttpHeaders headers, @@ -124,6 +163,12 @@ protected ResponseEntity handleMissingServletRequestParameter(MissingSer } + /** + * Handles parking area not found exception. + * + * @param ex The ParkingAreaNotFoundException thrown + * @return ResponseEntity with an error response + */ @ExceptionHandler(value = {ParkingAreaNotFoundException.class}) protected ResponseEntity handleParkingAreaNotFoundException(final ParkingAreaNotFoundException ex) { @@ -143,6 +188,12 @@ protected ResponseEntity handleParkingAreaNotFoundException(final } + /** + * Handles park not found exception. + * + * @param ex The ParkNotFoundException thrown + * @return ResponseEntity with an error response + */ @ExceptionHandler(value = {ParkNotFoundException.class}) protected ResponseEntity handleParkNotFoundException(final ParkNotFoundException ex) { @@ -162,6 +213,12 @@ protected ResponseEntity handleParkNotFoundException(final ParkNo } + /** + * Handles price list not found exception. + * + * @param ex The PriceListNotFoundException thrown + * @return ResponseEntity with an error response + */ @ExceptionHandler(value = {PriceListNotFoundException.class}) protected ResponseEntity handlePriceListNotFoundException(final PriceListNotFoundException ex) { @@ -181,6 +238,12 @@ protected ResponseEntity handlePriceListNotFoundException(final P } + /** + * Handles email already exists exception. + * + * @param ex The EmailAlreadyExistsException thrown + * @return ResponseEntity with an error response + */ @ExceptionHandler(value = {EmailAlreadyExistsException.class}) protected ResponseEntity handleEmailAlreadyExistsException(final EmailAlreadyExistsException ex) { @@ -200,6 +263,12 @@ protected ResponseEntity handleEmailAlreadyExistsException(final } + /** + * Handles refresh token not found exception. + * + * @param ex The RefreshTokenNotFoundException thrown + * @return ResponseEntity with an error response + */ @ExceptionHandler(value = {RefreshTokenNotFoundException.class}) protected ResponseEntity handleRefreshTokenNotFoundException(final RefreshTokenNotFoundException ex) { @@ -220,6 +289,12 @@ protected ResponseEntity handleRefreshTokenNotFoundException(fina } + /** + * Handles user not found exception. + * + * @param ex The UserNotFoundException thrown + * @return ResponseEntity with an error response + */ @ExceptionHandler(value = {UserNotFoundException.class}) protected ResponseEntity handleUserNotFoundException(final UserNotFoundException ex) { @@ -239,6 +314,12 @@ protected ResponseEntity handleUserNotFoundException(final UserNo } + /** + * Handles parking area already exists exception. + * + * @param ex The ParkingAreaAlreadyExistException thrown + * @return ResponseEntity with an error response + */ @ExceptionHandler(ParkingAreaAlreadyExistException.class) protected ResponseEntity handleParkingAreAlreadyExistException(final ParkingAreaAlreadyExistException ex) { @@ -258,6 +339,12 @@ protected ResponseEntity handleParkingAreAlreadyExistException(fi } + /** + * Handles parking area capacity not null exception. + * + * @param ex The ParkingAreaCapacityCanNotBeNullException thrown + * @return ResponseEntity with an error response + */ @ExceptionHandler(ParkingAreaCapacityCanNotBeNullException.class) protected ResponseEntity handleParkingAreaNotFoundException(final ParkingAreaCapacityCanNotBeNullException ex) { @@ -277,6 +364,12 @@ protected ResponseEntity handleParkingAreaNotFoundException(final } + /** + * Handles vehicle already exist exception. + * + * @param ex The VehicleAlreadyExist thrown + * @return ResponseEntity with an error response + */ @ExceptionHandler(VehicleAlreadyExist.class) protected ResponseEntity handleUserAlreadyHasThisVehicleException(final VehicleAlreadyExist ex){ diff --git a/src/main/java/com/project/parkinglot/exception/NotFoundException.java b/src/main/java/com/project/parkinglot/exception/NotFoundException.java index 43e995d..5cb43bf 100644 --- a/src/main/java/com/project/parkinglot/exception/NotFoundException.java +++ b/src/main/java/com/project/parkinglot/exception/NotFoundException.java @@ -5,6 +5,10 @@ import java.io.Serial; +/** + * An abstract exception class representing the scenario where an entity is not found. + * This exception should be extended by specific exception classes for different entities. + */ public abstract class NotFoundException extends RuntimeException { @Serial diff --git a/src/main/java/com/project/parkinglot/exception/park/ParkNotFoundException.java b/src/main/java/com/project/parkinglot/exception/park/ParkNotFoundException.java index 78b6f2e..11c3e37 100644 --- a/src/main/java/com/project/parkinglot/exception/park/ParkNotFoundException.java +++ b/src/main/java/com/project/parkinglot/exception/park/ParkNotFoundException.java @@ -4,6 +4,9 @@ import java.io.Serial; +/** + * Exception class named {@link ParkNotFoundException} thrown when a park entity is not found. + */ public class ParkNotFoundException extends NotFoundException { @Serial diff --git a/src/main/java/com/project/parkinglot/exception/parkingarea/DailyIncomeException.java b/src/main/java/com/project/parkinglot/exception/parkingarea/DailyIncomeException.java index d699687..400a552 100644 --- a/src/main/java/com/project/parkinglot/exception/parkingarea/DailyIncomeException.java +++ b/src/main/java/com/project/parkinglot/exception/parkingarea/DailyIncomeException.java @@ -2,6 +2,9 @@ import java.io.Serial; +/** + * Exception class named {@link DailyIncomeException} thrown when daily income information is not found for the given ID and Date. + */ public class DailyIncomeException extends RuntimeException { @Serial diff --git a/src/main/java/com/project/parkinglot/exception/parkingarea/InvalidDateException.java b/src/main/java/com/project/parkinglot/exception/parkingarea/InvalidDateException.java index 9beca21..697bad9 100644 --- a/src/main/java/com/project/parkinglot/exception/parkingarea/InvalidDateException.java +++ b/src/main/java/com/project/parkinglot/exception/parkingarea/InvalidDateException.java @@ -2,6 +2,9 @@ import java.io.Serial; +/** + * Exception class named {@link InvalidDateException} thrown when a date is invalid for processing. + */ public class InvalidDateException extends RuntimeException { @Serial diff --git a/src/main/java/com/project/parkinglot/exception/parkingarea/ParkingAreaAlreadyExistException.java b/src/main/java/com/project/parkinglot/exception/parkingarea/ParkingAreaAlreadyExistException.java index 5406b79..e552a6a 100644 --- a/src/main/java/com/project/parkinglot/exception/parkingarea/ParkingAreaAlreadyExistException.java +++ b/src/main/java/com/project/parkinglot/exception/parkingarea/ParkingAreaAlreadyExistException.java @@ -4,6 +4,9 @@ import java.io.Serial; +/** + * Exception class named {@link ParkingAreaAlreadyExistException} thrown when a parking area already exists. + */ public class ParkingAreaAlreadyExistException extends AlreadyException { @Serial diff --git a/src/main/java/com/project/parkinglot/exception/parkingarea/ParkingAreaCapacityCanNotBeNullException.java b/src/main/java/com/project/parkinglot/exception/parkingarea/ParkingAreaCapacityCanNotBeNullException.java index eec5758..f6325e6 100644 --- a/src/main/java/com/project/parkinglot/exception/parkingarea/ParkingAreaCapacityCanNotBeNullException.java +++ b/src/main/java/com/project/parkinglot/exception/parkingarea/ParkingAreaCapacityCanNotBeNullException.java @@ -2,6 +2,9 @@ import java.io.Serial; +/** + * Exception class named {@link ParkingAreaCapacityCanNotBeNullException} thrown when the capacity of a parking area is null. + */ public class ParkingAreaCapacityCanNotBeNullException extends RuntimeException { @Serial diff --git a/src/main/java/com/project/parkinglot/exception/parkingarea/ParkingAreaCapacityException.java b/src/main/java/com/project/parkinglot/exception/parkingarea/ParkingAreaCapacityException.java index 67944f3..2bf21c3 100644 --- a/src/main/java/com/project/parkinglot/exception/parkingarea/ParkingAreaCapacityException.java +++ b/src/main/java/com/project/parkinglot/exception/parkingarea/ParkingAreaCapacityException.java @@ -2,6 +2,9 @@ import java.io.Serial; +/** + * Exception class named {@link ParkingAreaCapacityException} thrown when the capacity of a parking area is not available. + */ public class ParkingAreaCapacityException extends RuntimeException { @Serial diff --git a/src/main/java/com/project/parkinglot/exception/parkingarea/ParkingAreaNotFoundException.java b/src/main/java/com/project/parkinglot/exception/parkingarea/ParkingAreaNotFoundException.java index 82c8dff..06e3714 100644 --- a/src/main/java/com/project/parkinglot/exception/parkingarea/ParkingAreaNotFoundException.java +++ b/src/main/java/com/project/parkinglot/exception/parkingarea/ParkingAreaNotFoundException.java @@ -4,6 +4,9 @@ import java.io.Serial; +/** + * Exception class named {@link ParkingAreaNotFoundException} thrown when a parking area is not found. + */ public class ParkingAreaNotFoundException extends NotFoundException { @Serial diff --git a/src/main/java/com/project/parkinglot/exception/pricelist/PriceListNotFoundException.java b/src/main/java/com/project/parkinglot/exception/pricelist/PriceListNotFoundException.java index 2189849..3ffb6d6 100644 --- a/src/main/java/com/project/parkinglot/exception/pricelist/PriceListNotFoundException.java +++ b/src/main/java/com/project/parkinglot/exception/pricelist/PriceListNotFoundException.java @@ -4,6 +4,9 @@ import java.io.Serial; +/** + * Exception class named {@link PriceListNotFoundException} thrown when a price list is not found. + */ public class PriceListNotFoundException extends NotFoundException { @Serial diff --git a/src/main/java/com/project/parkinglot/exception/user/EmailAlreadyExistsException.java b/src/main/java/com/project/parkinglot/exception/user/EmailAlreadyExistsException.java index 517bc95..0a2b39c 100644 --- a/src/main/java/com/project/parkinglot/exception/user/EmailAlreadyExistsException.java +++ b/src/main/java/com/project/parkinglot/exception/user/EmailAlreadyExistsException.java @@ -4,6 +4,9 @@ import java.io.Serial; +/** + * Exception class named {@link EmailAlreadyExistsException} thrown when an email already exists in the system. + */ public class EmailAlreadyExistsException extends AlreadyException { @Serial diff --git a/src/main/java/com/project/parkinglot/exception/user/RefreshTokenNotFoundException.java b/src/main/java/com/project/parkinglot/exception/user/RefreshTokenNotFoundException.java index 16ae381..8e33455 100644 --- a/src/main/java/com/project/parkinglot/exception/user/RefreshTokenNotFoundException.java +++ b/src/main/java/com/project/parkinglot/exception/user/RefreshTokenNotFoundException.java @@ -4,6 +4,9 @@ import java.io.Serial; +/** + * Exception class named {@link RefreshTokenNotFoundException} thrown when a refresh token is not found. + */ public class RefreshTokenNotFoundException extends NotFoundException { @Serial diff --git a/src/main/java/com/project/parkinglot/exception/user/UserNotFoundException.java b/src/main/java/com/project/parkinglot/exception/user/UserNotFoundException.java index 3574535..3dd0d22 100644 --- a/src/main/java/com/project/parkinglot/exception/user/UserNotFoundException.java +++ b/src/main/java/com/project/parkinglot/exception/user/UserNotFoundException.java @@ -4,6 +4,9 @@ import java.io.Serial; +/** + * Exception class named {@link UserNotFoundException} thrown when a user is not found. + */ public class UserNotFoundException extends NotFoundException { @Serial diff --git a/src/main/java/com/project/parkinglot/exception/vehicle/VehicleAlreadyExist.java b/src/main/java/com/project/parkinglot/exception/vehicle/VehicleAlreadyExist.java index 3e83737..226581d 100644 --- a/src/main/java/com/project/parkinglot/exception/vehicle/VehicleAlreadyExist.java +++ b/src/main/java/com/project/parkinglot/exception/vehicle/VehicleAlreadyExist.java @@ -2,6 +2,9 @@ import java.io.Serial; +/** + * Exception class named {@link VehicleAlreadyExist} thrown when a user tries to add a vehicle that already exists. + */ public class VehicleAlreadyExist extends RuntimeException{ @Serial diff --git a/src/main/java/com/project/parkinglot/exception/vehicle/VehicleNotFoundException.java b/src/main/java/com/project/parkinglot/exception/vehicle/VehicleNotFoundException.java index 80714f3..fb6ddb2 100644 --- a/src/main/java/com/project/parkinglot/exception/vehicle/VehicleNotFoundException.java +++ b/src/main/java/com/project/parkinglot/exception/vehicle/VehicleNotFoundException.java @@ -4,6 +4,9 @@ import java.io.Serial; +/** + * Exception class named {@link VehicleNotFoundException} thrown when a vehicle is not found. + */ public class VehicleNotFoundException extends NotFoundException { @Serial diff --git a/src/main/java/com/project/parkinglot/logging/aop/LoggerAspectJ.java b/src/main/java/com/project/parkinglot/logging/aop/LoggerAspectJ.java index a7f37d9..b4ffa2a 100644 --- a/src/main/java/com/project/parkinglot/logging/aop/LoggerAspectJ.java +++ b/src/main/java/com/project/parkinglot/logging/aop/LoggerAspectJ.java @@ -26,6 +26,9 @@ import java.io.IOException; import java.util.Optional; +/** + * Aspect class {@link LoggerAspectJ} for logging requests and responses of Spring REST Controllers. + */ @Aspect @Slf4j @Component @@ -34,11 +37,20 @@ public class LoggerAspectJ { private final LogService logService; + /** + * Defines a pointcut for Spring REST Controllers. + */ @Pointcut("within(@org.springframework.web.bind.annotation.RestController *)") public void restControllerPointcut() { } + /** + * Advice method to log exceptions thrown from RestControllers. + * + * @param joinPoint The join point where the exception occurred. + * @param ex The exception that was thrown. + */ @AfterThrowing(pointcut = "restControllerPointcut()", throwing = "ex") public void logAfterThrowing(JoinPoint joinPoint, Exception ex) { @@ -77,6 +89,13 @@ public void logAfterThrowing(JoinPoint joinPoint, Exception ex) { } + /** + * Advice method to log successful responses from RestControllers. + * + * @param joinPoint The join point where the response was generated. + * @param result The result returned by the controller method. + * @throws IOException If there is an error while converting the response to a JSON string. + */ @AfterReturning(value = "restControllerPointcut()", returning = "result") public void logAfterReturning(JoinPoint joinPoint, Object result) throws IOException { @@ -123,6 +142,12 @@ public void logAfterReturning(JoinPoint joinPoint, Object result) throws IOExcep } } + /** + * Helper method to determine HttpStatus from an exception. + * + * @param ex The exception for which to determine the HttpStatus. + * @return The HttpStatus corresponding to the exception, or null if not recognized. + */ private HttpStatus getHttpStatusFromException(Exception ex) { if (ex instanceof NotFoundException) { diff --git a/src/main/java/com/project/parkinglot/logging/entity/LogEntity.java b/src/main/java/com/project/parkinglot/logging/entity/LogEntity.java index e1d47ff..4337f64 100644 --- a/src/main/java/com/project/parkinglot/logging/entity/LogEntity.java +++ b/src/main/java/com/project/parkinglot/logging/entity/LogEntity.java @@ -6,6 +6,9 @@ import java.time.LocalDateTime; +/** + * Entity class named {@link LogEntity} representing logs of the parking lot. + */ @Entity @Data @EqualsAndHashCode(callSuper = false) diff --git a/src/main/java/com/project/parkinglot/logging/repository/LogRepository.java b/src/main/java/com/project/parkinglot/logging/repository/LogRepository.java index f85ce74..1efc12d 100644 --- a/src/main/java/com/project/parkinglot/logging/repository/LogRepository.java +++ b/src/main/java/com/project/parkinglot/logging/repository/LogRepository.java @@ -3,5 +3,8 @@ import com.project.parkinglot.logging.entity.LogEntity; import org.springframework.data.jpa.repository.JpaRepository; +/** + * Repository interface named {@link LogRepository} for managing log entity persistence. + */ public interface LogRepository extends JpaRepository { } diff --git a/src/main/java/com/project/parkinglot/logging/service/LogService.java b/src/main/java/com/project/parkinglot/logging/service/LogService.java index 533b271..576c955 100644 --- a/src/main/java/com/project/parkinglot/logging/service/LogService.java +++ b/src/main/java/com/project/parkinglot/logging/service/LogService.java @@ -2,8 +2,16 @@ import com.project.parkinglot.logging.entity.LogEntity; +/** + * Service interface named {@link LogService} for managing log entities. + */ public interface LogService { + /** + * Saves a log entity to the database. + * + * @param logEntity The log entity to be saved + */ void saveLogToDatabase(LogEntity logEntity); } diff --git a/src/main/java/com/project/parkinglot/logging/service/impl/LogServiceImpl.java b/src/main/java/com/project/parkinglot/logging/service/impl/LogServiceImpl.java index 4f963c2..d8bdadf 100644 --- a/src/main/java/com/project/parkinglot/logging/service/impl/LogServiceImpl.java +++ b/src/main/java/com/project/parkinglot/logging/service/impl/LogServiceImpl.java @@ -8,12 +8,20 @@ import java.time.LocalDateTime; +/** + * Service named {@link LogServiceImpl} implementation for managing log entities. + */ @Service @RequiredArgsConstructor public class LogServiceImpl implements LogService { private final LogRepository logRepository; + /** + * Saves a log entity to the database. + * + * @param logEntity The log entity to be saved + */ @Override public void saveLogToDatabase(LogEntity logEntity) { diff --git a/src/main/java/com/project/parkinglot/model/Park.java b/src/main/java/com/project/parkinglot/model/Park.java index f14961d..be65735 100644 --- a/src/main/java/com/project/parkinglot/model/Park.java +++ b/src/main/java/com/project/parkinglot/model/Park.java @@ -8,6 +8,9 @@ import java.math.BigDecimal; import java.time.LocalDateTime; +/** + * Represents a park domain model object named {@link Park}. + */ @Getter @Setter @SuperBuilder diff --git a/src/main/java/com/project/parkinglot/model/ParkingArea.java b/src/main/java/com/project/parkinglot/model/ParkingArea.java index d2e8c9b..3d2e1c6 100644 --- a/src/main/java/com/project/parkinglot/model/ParkingArea.java +++ b/src/main/java/com/project/parkinglot/model/ParkingArea.java @@ -6,6 +6,9 @@ import java.util.List; +/** + * Represents a parking area domain model object named {@link ParkingArea}. + */ @Getter @Setter @SuperBuilder diff --git a/src/main/java/com/project/parkinglot/model/Price.java b/src/main/java/com/project/parkinglot/model/Price.java index ee4426f..05113b9 100644 --- a/src/main/java/com/project/parkinglot/model/Price.java +++ b/src/main/java/com/project/parkinglot/model/Price.java @@ -8,7 +8,7 @@ import java.math.BigDecimal; /** - * Domain Model of {@link PriceEntity} + * Represents a price domain model object named {@link Price}. */ @Getter @Setter diff --git a/src/main/java/com/project/parkinglot/model/PriceList.java b/src/main/java/com/project/parkinglot/model/PriceList.java index 3255380..e4ed46a 100644 --- a/src/main/java/com/project/parkinglot/model/PriceList.java +++ b/src/main/java/com/project/parkinglot/model/PriceList.java @@ -8,7 +8,7 @@ import java.util.List; /** - * Domain Model of {@link PriceListEntity} + * Represents a pricelist domain model object named {@link PriceList}. */ @Getter @Setter diff --git a/src/main/java/com/project/parkinglot/model/User.java b/src/main/java/com/project/parkinglot/model/User.java index 5dcf67f..79a4b4f 100644 --- a/src/main/java/com/project/parkinglot/model/User.java +++ b/src/main/java/com/project/parkinglot/model/User.java @@ -7,6 +7,9 @@ import java.util.List; +/** + * Represents a user domain model object named {@link User}. + */ @Getter @Setter @SuperBuilder diff --git a/src/main/java/com/project/parkinglot/model/Vehicle.java b/src/main/java/com/project/parkinglot/model/Vehicle.java index 7e158a0..024b294 100644 --- a/src/main/java/com/project/parkinglot/model/Vehicle.java +++ b/src/main/java/com/project/parkinglot/model/Vehicle.java @@ -7,6 +7,9 @@ import java.util.List; +/** + * Represents a vehicle domain model object named {@link Vehicle}. + */ @Getter @Setter @SuperBuilder diff --git a/src/main/java/com/project/parkinglot/model/dto/request/park/ParkCheckInRequest.java b/src/main/java/com/project/parkinglot/model/dto/request/park/ParkCheckInRequest.java index 0dad14a..9da64dc 100644 --- a/src/main/java/com/project/parkinglot/model/dto/request/park/ParkCheckInRequest.java +++ b/src/main/java/com/project/parkinglot/model/dto/request/park/ParkCheckInRequest.java @@ -5,6 +5,9 @@ import jakarta.validation.constraints.NotNull; import lombok.*; +/** + * A request class named {@link ParkCheckInRequest} representing the check-in request for a vehicle at a parking area. + */ @Getter @Setter @NoArgsConstructor diff --git a/src/main/java/com/project/parkinglot/model/dto/request/park/ParkCheckOutRequest.java b/src/main/java/com/project/parkinglot/model/dto/request/park/ParkCheckOutRequest.java index 7842d52..a8d12fe 100644 --- a/src/main/java/com/project/parkinglot/model/dto/request/park/ParkCheckOutRequest.java +++ b/src/main/java/com/project/parkinglot/model/dto/request/park/ParkCheckOutRequest.java @@ -5,6 +5,9 @@ import jakarta.validation.constraints.NotNull; import lombok.*; +/** + * A request class named {@link ParkCheckOutRequest} representing the check-out request for a vehicle from a parking area. + */ @Getter @Setter @NoArgsConstructor diff --git a/src/main/java/com/project/parkinglot/model/dto/request/parking_area/ParkingAreaCreateRequest.java b/src/main/java/com/project/parkinglot/model/dto/request/parking_area/ParkingAreaCreateRequest.java index 3f16689..a4642d9 100644 --- a/src/main/java/com/project/parkinglot/model/dto/request/parking_area/ParkingAreaCreateRequest.java +++ b/src/main/java/com/project/parkinglot/model/dto/request/parking_area/ParkingAreaCreateRequest.java @@ -10,6 +10,9 @@ import lombok.NoArgsConstructor; import lombok.Setter; +/** + * A request class named {@link ParkingAreaCreateRequest} representing the update of a parking area. + */ @Getter @Setter @NoArgsConstructor diff --git a/src/main/java/com/project/parkinglot/model/dto/request/parking_area/ParkingAreaUpdateRequest.java b/src/main/java/com/project/parkinglot/model/dto/request/parking_area/ParkingAreaUpdateRequest.java index cc8cc07..696be1b 100644 --- a/src/main/java/com/project/parkinglot/model/dto/request/parking_area/ParkingAreaUpdateRequest.java +++ b/src/main/java/com/project/parkinglot/model/dto/request/parking_area/ParkingAreaUpdateRequest.java @@ -9,6 +9,9 @@ import lombok.NoArgsConstructor; import lombok.Setter; +/** + * A request class named {@link ParkingAreaUpdateRequest} representing the creation of a parking area. + */ @NoArgsConstructor @AllArgsConstructor @Getter diff --git a/src/main/java/com/project/parkinglot/model/dto/request/price/PriceCreateRequest.java b/src/main/java/com/project/parkinglot/model/dto/request/price/PriceCreateRequest.java index 60c4aa8..a048a26 100644 --- a/src/main/java/com/project/parkinglot/model/dto/request/price/PriceCreateRequest.java +++ b/src/main/java/com/project/parkinglot/model/dto/request/price/PriceCreateRequest.java @@ -10,6 +10,9 @@ import java.math.BigDecimal; +/** + * A request class named {@link PriceCreateRequest} representing the creation of a price. + */ @Getter @Setter @NoArgsConstructor diff --git a/src/main/java/com/project/parkinglot/model/dto/request/priceList/PriceListCreateRequest.java b/src/main/java/com/project/parkinglot/model/dto/request/priceList/PriceListCreateRequest.java index 99a0f2a..f6d5187 100644 --- a/src/main/java/com/project/parkinglot/model/dto/request/priceList/PriceListCreateRequest.java +++ b/src/main/java/com/project/parkinglot/model/dto/request/priceList/PriceListCreateRequest.java @@ -10,6 +10,9 @@ import java.util.List; +/** + * A request class named {@link PriceListCreateRequest} representing the creation of a price list. + */ @Getter @Setter @NoArgsConstructor diff --git a/src/main/java/com/project/parkinglot/model/dto/request/vehicle/VehicleRequest.java b/src/main/java/com/project/parkinglot/model/dto/request/vehicle/VehicleRequest.java index fbba6d4..80d9583 100644 --- a/src/main/java/com/project/parkinglot/model/dto/request/vehicle/VehicleRequest.java +++ b/src/main/java/com/project/parkinglot/model/dto/request/vehicle/VehicleRequest.java @@ -1,11 +1,14 @@ package com.project.parkinglot.model.dto.request.vehicle; +import com.project.parkinglot.model.dto.request.priceList.PriceListCreateRequest; import com.project.parkinglot.model.enums.VehicleType; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Size; import lombok.*; - +/** + * A request class named {@link VehicleRequest} representing licensePlate and vehicleType. + */ @Getter @Setter @NoArgsConstructor diff --git a/src/main/java/com/project/parkinglot/model/dto/response/ParkDetailResponse.java b/src/main/java/com/project/parkinglot/model/dto/response/ParkDetailResponse.java index e2701f4..0b8b247 100644 --- a/src/main/java/com/project/parkinglot/model/dto/response/ParkDetailResponse.java +++ b/src/main/java/com/project/parkinglot/model/dto/response/ParkDetailResponse.java @@ -1,12 +1,16 @@ package com.project.parkinglot.model.dto.response; import com.project.parkinglot.common.model.BaseDomainModel; +import com.project.parkinglot.model.dto.response.vehicle.VehicleCheckOutResponse; import lombok.*; import lombok.experimental.SuperBuilder; import java.math.BigDecimal; import java.time.LocalDateTime; +/** + * A response class named {@link ParkDetailResponse} representing the park detail response. + */ @Getter @Setter @SuperBuilder diff --git a/src/main/java/com/project/parkinglot/model/dto/response/VehicleParkingDetailResponse.java b/src/main/java/com/project/parkinglot/model/dto/response/VehicleParkingDetailResponse.java index 6f79b47..d0520ef 100644 --- a/src/main/java/com/project/parkinglot/model/dto/response/VehicleParkingDetailResponse.java +++ b/src/main/java/com/project/parkinglot/model/dto/response/VehicleParkingDetailResponse.java @@ -6,6 +6,9 @@ import java.util.List; +/** + * A response class named {@link VehicleParkingDetailResponse} representing the vehicle parking detail response. + */ @Getter @Setter @SuperBuilder diff --git a/src/main/java/com/project/parkinglot/model/dto/response/park/ParkCheckInResponse.java b/src/main/java/com/project/parkinglot/model/dto/response/park/ParkCheckInResponse.java index 6891a73..ea4afea 100644 --- a/src/main/java/com/project/parkinglot/model/dto/response/park/ParkCheckInResponse.java +++ b/src/main/java/com/project/parkinglot/model/dto/response/park/ParkCheckInResponse.java @@ -1,6 +1,7 @@ package com.project.parkinglot.model.dto.response.park; import com.project.parkinglot.common.model.BaseDomainModel; +import com.project.parkinglot.model.dto.request.park.ParkCheckInRequest; import com.project.parkinglot.model.dto.response.vehicle.VehicleCheckInResponse; import com.project.parkinglot.model.enums.ParkStatus; import lombok.*; @@ -8,6 +9,9 @@ import java.time.LocalDateTime; +/** + * A response class named {@link ParkCheckInResponse} representing the check-in response. + */ @Getter @Setter @SuperBuilder diff --git a/src/main/java/com/project/parkinglot/model/dto/response/park/ParkCheckOutResponse.java b/src/main/java/com/project/parkinglot/model/dto/response/park/ParkCheckOutResponse.java index b7ee769..a95dd85 100644 --- a/src/main/java/com/project/parkinglot/model/dto/response/park/ParkCheckOutResponse.java +++ b/src/main/java/com/project/parkinglot/model/dto/response/park/ParkCheckOutResponse.java @@ -9,6 +9,9 @@ import java.math.BigDecimal; import java.time.LocalDateTime; +/** + * A response class named {@link ParkCheckOutResponse} representing the check-out response. + */ @Getter @Setter @SuperBuilder diff --git a/src/main/java/com/project/parkinglot/model/dto/response/parkingarea/ParkingAreaIncomeResponse.java b/src/main/java/com/project/parkinglot/model/dto/response/parkingarea/ParkingAreaIncomeResponse.java index 33b0db8..d59d8e7 100644 --- a/src/main/java/com/project/parkinglot/model/dto/response/parkingarea/ParkingAreaIncomeResponse.java +++ b/src/main/java/com/project/parkinglot/model/dto/response/parkingarea/ParkingAreaIncomeResponse.java @@ -1,9 +1,13 @@ package com.project.parkinglot.model.dto.response.parkingarea; +import com.project.parkinglot.model.dto.response.park.ParkCheckOutResponse; import lombok.*; import java.math.BigDecimal; +/** + * A response class named {@link ParkingAreaIncomeResponse} representing the parking area income response. + */ @Getter @Setter @NoArgsConstructor diff --git a/src/main/java/com/project/parkinglot/model/dto/response/vehicle/VehicleCheckInResponse.java b/src/main/java/com/project/parkinglot/model/dto/response/vehicle/VehicleCheckInResponse.java index 9e358cc..c03ade8 100644 --- a/src/main/java/com/project/parkinglot/model/dto/response/vehicle/VehicleCheckInResponse.java +++ b/src/main/java/com/project/parkinglot/model/dto/response/vehicle/VehicleCheckInResponse.java @@ -1,8 +1,12 @@ package com.project.parkinglot.model.dto.response.vehicle; +import com.project.parkinglot.model.dto.response.parkingarea.ParkingAreaIncomeResponse; import com.project.parkinglot.model.enums.VehicleType; import lombok.*; +/** + * A response class named {@link VehicleCheckInResponse} representing the vehicle check-in response. + */ @Getter @Setter @NoArgsConstructor diff --git a/src/main/java/com/project/parkinglot/model/dto/response/vehicle/VehicleCheckOutResponse.java b/src/main/java/com/project/parkinglot/model/dto/response/vehicle/VehicleCheckOutResponse.java index 98d0bf2..5496c71 100644 --- a/src/main/java/com/project/parkinglot/model/dto/response/vehicle/VehicleCheckOutResponse.java +++ b/src/main/java/com/project/parkinglot/model/dto/response/vehicle/VehicleCheckOutResponse.java @@ -3,6 +3,9 @@ import com.project.parkinglot.model.enums.VehicleType; import lombok.*; +/** + * A response class named {@link VehicleCheckOutResponse} representing the vehicle check-out response. + */ @Getter @Setter @NoArgsConstructor diff --git a/src/main/java/com/project/parkinglot/model/entity/ParkEntity.java b/src/main/java/com/project/parkinglot/model/entity/ParkEntity.java index befd6de..0513056 100644 --- a/src/main/java/com/project/parkinglot/model/entity/ParkEntity.java +++ b/src/main/java/com/project/parkinglot/model/entity/ParkEntity.java @@ -9,6 +9,9 @@ import java.math.BigDecimal; import java.time.LocalDateTime; +/** + * Represents an entity named {@link ParkEntity} for park. + */ @Getter @Setter @EqualsAndHashCode(callSuper = true) diff --git a/src/main/java/com/project/parkinglot/model/entity/ParkingAreaEntity.java b/src/main/java/com/project/parkinglot/model/entity/ParkingAreaEntity.java index 1fe56b1..4ab523d 100644 --- a/src/main/java/com/project/parkinglot/model/entity/ParkingAreaEntity.java +++ b/src/main/java/com/project/parkinglot/model/entity/ParkingAreaEntity.java @@ -21,6 +21,9 @@ import java.util.List; +/** + * Represents an entity named {@link ParkingAreaEntity} for parking area. + */ @Getter @Setter @EqualsAndHashCode(callSuper = true) diff --git a/src/main/java/com/project/parkinglot/model/entity/PriceEntity.java b/src/main/java/com/project/parkinglot/model/entity/PriceEntity.java index 0eab6e5..156b165 100644 --- a/src/main/java/com/project/parkinglot/model/entity/PriceEntity.java +++ b/src/main/java/com/project/parkinglot/model/entity/PriceEntity.java @@ -10,6 +10,9 @@ import java.math.BigDecimal; +/** + * Represents an entity named {@link PriceEntity} for price. + */ @Data @EqualsAndHashCode(callSuper = true) @SuperBuilder diff --git a/src/main/java/com/project/parkinglot/model/entity/PriceListEntity.java b/src/main/java/com/project/parkinglot/model/entity/PriceListEntity.java index c788900..670e189 100644 --- a/src/main/java/com/project/parkinglot/model/entity/PriceListEntity.java +++ b/src/main/java/com/project/parkinglot/model/entity/PriceListEntity.java @@ -7,6 +7,9 @@ import java.util.List; +/** + * Represents an entity named {@link PriceListEntity} for price list. + */ @Getter @Setter @EqualsAndHashCode(callSuper = true) diff --git a/src/main/java/com/project/parkinglot/model/entity/VehicleEntity.java b/src/main/java/com/project/parkinglot/model/entity/VehicleEntity.java index 4d3f739..b000c92 100644 --- a/src/main/java/com/project/parkinglot/model/entity/VehicleEntity.java +++ b/src/main/java/com/project/parkinglot/model/entity/VehicleEntity.java @@ -9,6 +9,9 @@ import java.util.List; +/** + * Represents an entity named {@link VehicleEntity} for vehicle. + */ @Getter @Setter @EqualsAndHashCode(callSuper = true) diff --git a/src/main/java/com/project/parkinglot/model/enums/ParkStatus.java b/src/main/java/com/project/parkinglot/model/enums/ParkStatus.java index f851e5b..7c07d63 100644 --- a/src/main/java/com/project/parkinglot/model/enums/ParkStatus.java +++ b/src/main/java/com/project/parkinglot/model/enums/ParkStatus.java @@ -3,6 +3,9 @@ import lombok.Getter; import lombok.RequiredArgsConstructor; +/** + * Enumeration named {@link ParkStatus} representing the status of a park. + */ @Getter @RequiredArgsConstructor public enum ParkStatus { diff --git a/src/main/java/com/project/parkinglot/model/enums/VehicleType.java b/src/main/java/com/project/parkinglot/model/enums/VehicleType.java index 4f3ebca..01484cc 100644 --- a/src/main/java/com/project/parkinglot/model/enums/VehicleType.java +++ b/src/main/java/com/project/parkinglot/model/enums/VehicleType.java @@ -4,6 +4,9 @@ import lombok.Getter; import lombok.RequiredArgsConstructor; +/** + * Enumeration named {@link VehicleType} representing the status of a vehicle. + */ @Getter @RequiredArgsConstructor public enum VehicleType { diff --git a/src/main/java/com/project/parkinglot/model/mapper/BaseMapper.java b/src/main/java/com/project/parkinglot/model/mapper/BaseMapper.java index a1503eb..99b531f 100644 --- a/src/main/java/com/project/parkinglot/model/mapper/BaseMapper.java +++ b/src/main/java/com/project/parkinglot/model/mapper/BaseMapper.java @@ -3,8 +3,28 @@ import java.util.Collection; import java.util.List; +/** + * Base mapper interface named {@link BaseMapper} for mapping between two objects. + * + * @param The source object type. + * @param The target object type. + */ public interface BaseMapper { + /** + * Maps a source object to a target object. + * + * @param source The source object to map. + * @return The mapped target object. + */ T map(S source); + + /** + * Maps a collection of source objects to a list of target objects. + * + * @param sources The collection of source objects to map. + * @return The list of mapped target objects. + */ List map(Collection sources); + } diff --git a/src/main/java/com/project/parkinglot/model/mapper/park/ParkCheckInRequestToParkEntityMapper.java b/src/main/java/com/project/parkinglot/model/mapper/park/ParkCheckInRequestToParkEntityMapper.java index e1cbea7..ca010dd 100644 --- a/src/main/java/com/project/parkinglot/model/mapper/park/ParkCheckInRequestToParkEntityMapper.java +++ b/src/main/java/com/project/parkinglot/model/mapper/park/ParkCheckInRequestToParkEntityMapper.java @@ -7,14 +7,28 @@ import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; +/** + * Mapper interface named {@link ParkCheckInRequestToParkEntityMapper} to convert {@link ParkCheckInRequest} objects to {@link ParkEntity} objects. + */ @Mapper public interface ParkCheckInRequestToParkEntityMapper extends BaseMapper { + /** + * Maps a {@link ParkCheckInRequest} object to a {@link ParkEntity} object. + * + * @param source The {@link ParkCheckInRequest} object to map. + * @return The mapped {@link ParkEntity} object. + */ @Override @Mapping(source = "parkingAreaId", target = "parkingAreaEntity.id") @Mapping(source = "vehicle", target = "vehicleEntity") ParkEntity map(ParkCheckInRequest source); + /** + * Initializes the mapper. + * + * @return An instance of {@link ParkCheckInRequestToParkEntityMapper}. + */ static ParkCheckInRequestToParkEntityMapper initialize() { return Mappers.getMapper(ParkCheckInRequestToParkEntityMapper.class); } diff --git a/src/main/java/com/project/parkinglot/model/mapper/park/ParkEntityToParkCheckOutResponseMapper.java b/src/main/java/com/project/parkinglot/model/mapper/park/ParkEntityToParkCheckOutResponseMapper.java index 0ab1c21..ab590ca 100644 --- a/src/main/java/com/project/parkinglot/model/mapper/park/ParkEntityToParkCheckOutResponseMapper.java +++ b/src/main/java/com/project/parkinglot/model/mapper/park/ParkEntityToParkCheckOutResponseMapper.java @@ -7,10 +7,19 @@ import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; +/** + * Mapper interface named {@link ParkEntityToParkCheckOutResponseMapper} to convert {@link ParkEntity} objects to {@link ParkCheckOutResponse} objects. + */ @Mapper public interface ParkEntityToParkCheckOutResponseMapper extends BaseMapper { + /** + * Maps a {@link ParkEntity} object to a {@link ParkCheckOutResponse} object. + * + * @param source The {@link ParkEntity} object to map. + * @return The mapped {@link ParkCheckOutResponse} object. + */ @Override @Mapping(source = "parkingAreaEntity.id", target = "parkingAreaId") @Mapping(source = "parkingAreaEntity.name", target = "parkingAreaName") @@ -20,6 +29,11 @@ public interface ParkEntityToParkCheckOutResponseMapper extends BaseMapper { + /** + * Maps a {@link ParkEntity} object to a {@link ParkDetailResponse} object. + * + * @param source The {@link ParkEntity} object to map. + * @return The mapped {@link ParkDetailResponse} object. + */ @Override @Mapping(source = "checkIn", target = "checkInDate") @Mapping(source = "checkOut", target = "checkOutDate") @@ -17,7 +26,11 @@ public interface ParkEntityToParkDetailResponse extends BaseMapper { + /** + * Maps a {@link ParkEntity} object to a {@link Park} object. + * + * @param source The {@link ParkEntity} object to map. + * @return The mapped {@link Park} object. + */ @Override @Mapping(source = "parkingAreaEntity", target = "parkingArea") @Mapping(source = "vehicleEntity", target = "vehicle") Park map(ParkEntity source); - + /** + * Initializes the mapper. + * + * @return An instance of {@link ParkEntityToParkMapper}. + */ static ParkEntityToParkMapper initialize() { return Mappers.getMapper(ParkEntityToParkMapper.class); } diff --git a/src/main/java/com/project/parkinglot/model/mapper/park/ParkToParkCheckInResponseMapper.java b/src/main/java/com/project/parkinglot/model/mapper/park/ParkToParkCheckInResponseMapper.java index 1606bc3..f03b6cf 100644 --- a/src/main/java/com/project/parkinglot/model/mapper/park/ParkToParkCheckInResponseMapper.java +++ b/src/main/java/com/project/parkinglot/model/mapper/park/ParkToParkCheckInResponseMapper.java @@ -7,9 +7,18 @@ import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; +/** + * Mapper interface named {@link ParkToParkCheckInResponseMapper} to convert {@link Park} objects to {@link ParkCheckInResponse} objects. + */ @Mapper public interface ParkToParkCheckInResponseMapper extends BaseMapper { + /** + * Maps a {@link Park} object to a {@link ParkCheckInResponse} object. + * + * @param source The {@link Park} object to map. + * @return The mapped {@link ParkCheckInResponse} object. + */ @Override @Mapping(source = "parkingArea.id", target = "parkingAreaId") @Mapping(source = "vehicle", target = "vehicleCheckInResponse") @@ -17,6 +26,11 @@ public interface ParkToParkCheckInResponseMapper extends BaseMapper { + /** + * Maps a {@link Park} object to a {@link ParkEntity} object. + * + * @param source The {@link Park} object to map. + * @return The mapped {@link ParkEntity} object. + */ @Override @Mapping(source = "parkingArea", target = "parkingAreaEntity") @Mapping(source = "vehicle", target = "vehicleEntity") ParkEntity map(Park source); + /** + * Initializes the mapper. + * + * @return An instance of {@link ParkToParkEntityMapper}. + */ static ParkToParkEntityMapper initialize() { return Mappers.getMapper(ParkToParkEntityMapper.class); } diff --git a/src/main/java/com/project/parkinglot/model/mapper/parking_area/ParkingAreaCreateRequestToParkingAreaEntityMapper.java b/src/main/java/com/project/parkinglot/model/mapper/parking_area/ParkingAreaCreateRequestToParkingAreaEntityMapper.java index 4e5dba9..88d9d53 100644 --- a/src/main/java/com/project/parkinglot/model/mapper/parking_area/ParkingAreaCreateRequestToParkingAreaEntityMapper.java +++ b/src/main/java/com/project/parkinglot/model/mapper/parking_area/ParkingAreaCreateRequestToParkingAreaEntityMapper.java @@ -7,9 +7,18 @@ import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; +/** + * Mapper interface named {@link ParkingAreaCreateRequestToParkingAreaEntityMapper} to convert {@link ParkingAreaCreateRequest} objects to {@link ParkingAreaEntity} objects. + */ @Mapper public interface ParkingAreaCreateRequestToParkingAreaEntityMapper extends BaseMapper { + /** + * Maps a {@link ParkingAreaCreateRequest} object to a {@link ParkingAreaEntity} object. + * + * @param source The {@link ParkingAreaCreateRequest} object to map. + * @return The mapped {@link ParkingAreaEntity} object. + */ @Override @Mapping(target = "priceListEntity", ignore = true) ParkingAreaEntity map(ParkingAreaCreateRequest source); diff --git a/src/main/java/com/project/parkinglot/model/mapper/parking_area/ParkingAreaEntityToParkingAreaMapper.java b/src/main/java/com/project/parkinglot/model/mapper/parking_area/ParkingAreaEntityToParkingAreaMapper.java index 2fc6ee5..e5f0109 100644 --- a/src/main/java/com/project/parkinglot/model/mapper/parking_area/ParkingAreaEntityToParkingAreaMapper.java +++ b/src/main/java/com/project/parkinglot/model/mapper/parking_area/ParkingAreaEntityToParkingAreaMapper.java @@ -7,13 +7,27 @@ import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; +/** + * Mapper interface named {@link ParkingAreaEntityToParkingAreaMapper} to convert {@link ParkingAreaEntity} objects to {@link ParkingArea} objects. + */ @Mapper public interface ParkingAreaEntityToParkingAreaMapper extends BaseMapper { + /** + * Maps a {@link ParkingAreaEntity} object to a {@link ParkingArea} object. + * + * @param source The {@link ParkingAreaEntity} object to map. + * @return The mapped {@link ParkingArea} object. + */ @Override @Mapping(target = "priceList", ignore = true) ParkingArea map(ParkingAreaEntity source); + /** + * Initializes the mapper. + * + * @return The initialized mapper object. + */ static ParkingAreaEntityToParkingAreaMapper initialize() { return Mappers.getMapper(ParkingAreaEntityToParkingAreaMapper.class); } diff --git a/src/main/java/com/project/parkinglot/model/mapper/parking_area/ParkingAreaToParkingAreaEntityMapper.java b/src/main/java/com/project/parkinglot/model/mapper/parking_area/ParkingAreaToParkingAreaEntityMapper.java index 1a3f90d..5fdb537 100644 --- a/src/main/java/com/project/parkinglot/model/mapper/parking_area/ParkingAreaToParkingAreaEntityMapper.java +++ b/src/main/java/com/project/parkinglot/model/mapper/parking_area/ParkingAreaToParkingAreaEntityMapper.java @@ -6,12 +6,26 @@ import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; +/** + * Mapper interface named {@link ParkingAreaToParkingAreaEntityMapper} to convert {@link ParkingArea} objects to {@link ParkingAreaEntity} objects. + */ @Mapper public interface ParkingAreaToParkingAreaEntityMapper extends BaseMapper { + /** + * Maps a {@link ParkingArea} object to a {@link ParkingAreaEntity} object. + * + * @param source The {@link ParkingArea} object to map. + * @return The mapped {@link ParkingAreaEntity} object. + */ @Override ParkingAreaEntity map(ParkingArea source); + /** + * Initializes the mapper. + * + * @return The initialized mapper object. + */ static ParkingAreaToParkingAreaEntityMapper initialize(){ return Mappers.getMapper(ParkingAreaToParkingAreaEntityMapper.class); } diff --git a/src/main/java/com/project/parkinglot/model/mapper/price/PriceDTOMapper.java b/src/main/java/com/project/parkinglot/model/mapper/price/PriceDTOMapper.java index a51ff73..8372642 100644 --- a/src/main/java/com/project/parkinglot/model/mapper/price/PriceDTOMapper.java +++ b/src/main/java/com/project/parkinglot/model/mapper/price/PriceDTOMapper.java @@ -3,8 +3,17 @@ import com.project.parkinglot.model.dto.request.price.PriceCreateRequest; import com.project.parkinglot.model.entity.PriceEntity; +/** + * Mapper class named {@link PriceDTOMapper} to map {@link PriceCreateRequest} to {@link PriceEntity} for saving. + */ public class PriceDTOMapper { + /** + * Maps a {@link PriceCreateRequest} object to a {@link PriceEntity} object for saving. + * + * @param priceCreateRequest The {@link PriceCreateRequest} object to map. + * @return The mapped {@link PriceEntity} object. + */ public static PriceEntity mapForSaving( final PriceCreateRequest priceCreateRequest ) { diff --git a/src/main/java/com/project/parkinglot/model/mapper/price/PriceMapper.java b/src/main/java/com/project/parkinglot/model/mapper/price/PriceMapper.java index 6cf394d..156517b 100644 --- a/src/main/java/com/project/parkinglot/model/mapper/price/PriceMapper.java +++ b/src/main/java/com/project/parkinglot/model/mapper/price/PriceMapper.java @@ -3,8 +3,17 @@ import com.project.parkinglot.model.Price; import com.project.parkinglot.model.entity.PriceEntity; +/** + * Mapper class named {@link PriceMapper} to map {@link PriceEntity} to {@link Price}. + */ public class PriceMapper { + /** + * Maps a {@link PriceEntity} object to a {@link Price} domain model object. + * + * @param priceEntity The {@link PriceEntity} object to map. + * @return The mapped {@link Price} domain model object. + */ public static Price toDomainModel( final PriceEntity priceEntity ) { diff --git a/src/main/java/com/project/parkinglot/model/mapper/priceList/PriceListDTOMapper.java b/src/main/java/com/project/parkinglot/model/mapper/priceList/PriceListDTOMapper.java index a73a2d6..3d46515 100644 --- a/src/main/java/com/project/parkinglot/model/mapper/priceList/PriceListDTOMapper.java +++ b/src/main/java/com/project/parkinglot/model/mapper/priceList/PriceListDTOMapper.java @@ -3,8 +3,17 @@ import com.project.parkinglot.model.dto.request.priceList.PriceListCreateRequest; import com.project.parkinglot.model.entity.PriceListEntity; +/** + * Mapper class named {@link PriceListDTOMapper} to map {@link PriceListCreateRequest} to {@link PriceListEntity} for saving. + */ public class PriceListDTOMapper { + /** + * Maps a {@link PriceListCreateRequest} object to a {@link PriceListEntity} object for saving. + * + * @param priceListCreateRequest The {@link PriceListCreateRequest} object to map. + * @return The mapped {@link PriceListEntity} object. + */ public static PriceListEntity mapForSaving( final PriceListCreateRequest priceListCreateRequest ) { diff --git a/src/main/java/com/project/parkinglot/model/mapper/priceList/PriceListMapper.java b/src/main/java/com/project/parkinglot/model/mapper/priceList/PriceListMapper.java index b440359..b4e4300 100644 --- a/src/main/java/com/project/parkinglot/model/mapper/priceList/PriceListMapper.java +++ b/src/main/java/com/project/parkinglot/model/mapper/priceList/PriceListMapper.java @@ -4,8 +4,17 @@ import com.project.parkinglot.model.entity.PriceListEntity; import com.project.parkinglot.model.mapper.price.PriceMapper; +/** + * Mapper class named {@link PriceListMapper} to map between {@link PriceList} and {@link PriceListEntity}. + */ public class PriceListMapper { + /** + * Maps a {@link PriceListEntity} object to a {@link PriceList} domain model. + * + * @param priceListEntity The {@link PriceListEntity} object to map. + * @return The mapped {@link PriceList} domain model object. + */ public static PriceList toDomainModel( final PriceListEntity priceListEntity ) { @@ -25,6 +34,12 @@ public static PriceList toDomainModel( .build(); } + /** + * Maps a {@link PriceList} domain model object to a {@link PriceListEntity} object. + * + * @param priceList The {@link PriceList} domain model object to map. + * @return The mapped {@link PriceListEntity} object. + */ public static PriceListEntity toEntity( final PriceList priceList ) { @@ -37,4 +52,5 @@ public static PriceListEntity toEntity( .updatedUser(priceList.getUpdatedUser()) .build(); } + } diff --git a/src/main/java/com/project/parkinglot/model/mapper/user/UserEntityToUserMapper.java b/src/main/java/com/project/parkinglot/model/mapper/user/UserEntityToUserMapper.java index 831ed7c..98247b1 100644 --- a/src/main/java/com/project/parkinglot/model/mapper/user/UserEntityToUserMapper.java +++ b/src/main/java/com/project/parkinglot/model/mapper/user/UserEntityToUserMapper.java @@ -8,13 +8,27 @@ import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; +/** + * Mapper interface named {@link UserEntityToUserMapper} to map from {@link UserEntity} to {@link User}. + */ @Mapper public interface UserEntityToUserMapper extends BaseMapper { + /** + * Maps a {@link UserEntity} object to a {@link User} domain model. + * + * @param source The {@link UserEntity} object to map. + * @return The mapped {@link User} domain model object. + */ @Override @Mapping(source = "vehicles", target = "vehicleList") User map(UserEntity source); + /** + * Initializes the mapper. + * + * @return The initialized mapper object. + */ static UserEntityToUserMapper initialize() { return Mappers.getMapper(UserEntityToUserMapper.class); } diff --git a/src/main/java/com/project/parkinglot/model/mapper/user/UserToUserEntityMapper.java b/src/main/java/com/project/parkinglot/model/mapper/user/UserToUserEntityMapper.java index 4bf8615..e4b6464 100644 --- a/src/main/java/com/project/parkinglot/model/mapper/user/UserToUserEntityMapper.java +++ b/src/main/java/com/project/parkinglot/model/mapper/user/UserToUserEntityMapper.java @@ -7,13 +7,27 @@ import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; +/** + * Mapper interface named {@link UserToUserEntityMapper} to map from {@link User} to {@link UserEntity}. + */ @Mapper public interface UserToUserEntityMapper extends BaseMapper { + /** + * Maps a {@link User} domain model object to a {@link UserEntity} object. + * + * @param source The {@link User} domain model object to map. + * @return The mapped {@link UserEntity} object. + */ @Override @Mapping(source = "vehicleList", target = "vehicles") UserEntity map(User source); + /** + * Initializes the mapper. + * + * @return The initialized mapper object. + */ static UserToUserEntityMapper initialize() { return Mappers.getMapper(UserToUserEntityMapper.class); } diff --git a/src/main/java/com/project/parkinglot/model/mapper/vehicle/VehicleEntityToVehicleMapper.java b/src/main/java/com/project/parkinglot/model/mapper/vehicle/VehicleEntityToVehicleMapper.java index 8b62b09..396fc9f 100644 --- a/src/main/java/com/project/parkinglot/model/mapper/vehicle/VehicleEntityToVehicleMapper.java +++ b/src/main/java/com/project/parkinglot/model/mapper/vehicle/VehicleEntityToVehicleMapper.java @@ -7,13 +7,27 @@ import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; +/** + * Mapper interface named {@link VehicleEntityToVehicleMapper} to map from {@link VehicleEntity} to {@link Vehicle}. + */ @Mapper public interface VehicleEntityToVehicleMapper extends BaseMapper { + /** + * Maps a {@link VehicleEntity} object to a {@link Vehicle} domain model object. + * + * @param source The {@link VehicleEntity} object to map. + * @return The mapped {@link Vehicle} domain model object. + */ @Override @Mapping(source = "parkEntities",target = "parkList") Vehicle map(VehicleEntity source); + /** + * Initializes the mapper. + * + * @return The initialized mapper object. + */ static VehicleEntityToVehicleMapper initialize(){ return Mappers.getMapper(VehicleEntityToVehicleMapper.class); } diff --git a/src/main/java/com/project/parkinglot/model/mapper/vehicle/VehicleRequestToVehicleMapper.java b/src/main/java/com/project/parkinglot/model/mapper/vehicle/VehicleRequestToVehicleMapper.java index 2e4fc3b..63a45f9 100644 --- a/src/main/java/com/project/parkinglot/model/mapper/vehicle/VehicleRequestToVehicleMapper.java +++ b/src/main/java/com/project/parkinglot/model/mapper/vehicle/VehicleRequestToVehicleMapper.java @@ -6,12 +6,26 @@ import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; +/** + * Mapper interface named {@link VehicleRequestToVehicleMapper} to map from {@link VehicleRequest} to {@link Vehicle}. + */ @Mapper public interface VehicleRequestToVehicleMapper extends BaseMapper { + /** + * Maps a {@link VehicleRequest} object to a {@link Vehicle} domain model object. + * + * @param source The {@link VehicleRequest} object to map. + * @return The mapped {@link Vehicle} domain model object. + */ @Override Vehicle map(VehicleRequest source); + /** + * Initializes the mapper. + * + * @return The initialized mapper object. + */ static VehicleRequestToVehicleMapper initialize(){ return Mappers.getMapper(VehicleRequestToVehicleMapper.class); } diff --git a/src/main/java/com/project/parkinglot/model/mapper/vehicle/VehicleToVehicleEntityMapper.java b/src/main/java/com/project/parkinglot/model/mapper/vehicle/VehicleToVehicleEntityMapper.java index ec64ad0..38f063c 100644 --- a/src/main/java/com/project/parkinglot/model/mapper/vehicle/VehicleToVehicleEntityMapper.java +++ b/src/main/java/com/project/parkinglot/model/mapper/vehicle/VehicleToVehicleEntityMapper.java @@ -7,13 +7,27 @@ import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; +/** + * Mapper interface named {@link VehicleToVehicleEntityMapper} to map from {@link Vehicle} to {@link VehicleEntity}. + */ @Mapper public interface VehicleToVehicleEntityMapper extends BaseMapper { + /** + * Maps a {@link Vehicle} object to a {@link VehicleEntity} object. + * + * @param source The {@link Vehicle} object to map. + * @return The mapped {@link VehicleEntity} object. + */ @Override @Mapping(source = "user", target = "userEntity") VehicleEntity map(Vehicle source); + /** + * Initializes the mapper. + * + * @return The initialized mapper object. + */ static VehicleToVehicleEntityMapper initialize(){ return Mappers.getMapper(VehicleToVehicleEntityMapper.class); } diff --git a/src/main/java/com/project/parkinglot/payload/request/auth/LoginRequest.java b/src/main/java/com/project/parkinglot/payload/request/auth/LoginRequest.java index 78a5c00..6a61d12 100644 --- a/src/main/java/com/project/parkinglot/payload/request/auth/LoginRequest.java +++ b/src/main/java/com/project/parkinglot/payload/request/auth/LoginRequest.java @@ -8,6 +8,9 @@ import lombok.Data; import lombok.NoArgsConstructor; +/** + * Represents a login request named {@link LoginRequest}. + */ @Data @AllArgsConstructor @NoArgsConstructor diff --git a/src/main/java/com/project/parkinglot/payload/request/auth/LogoutRequest.java b/src/main/java/com/project/parkinglot/payload/request/auth/LogoutRequest.java index 27f8726..9c0fe31 100644 --- a/src/main/java/com/project/parkinglot/payload/request/auth/LogoutRequest.java +++ b/src/main/java/com/project/parkinglot/payload/request/auth/LogoutRequest.java @@ -4,6 +4,9 @@ import lombok.Data; import lombok.NoArgsConstructor; +/** + * Represents a logout request named {@link LogoutRequest}. + */ @Data @AllArgsConstructor @NoArgsConstructor diff --git a/src/main/java/com/project/parkinglot/payload/request/auth/SignupRequest.java b/src/main/java/com/project/parkinglot/payload/request/auth/SignupRequest.java index 739eb34..8c3612e 100644 --- a/src/main/java/com/project/parkinglot/payload/request/auth/SignupRequest.java +++ b/src/main/java/com/project/parkinglot/payload/request/auth/SignupRequest.java @@ -9,6 +9,9 @@ import lombok.Data; import lombok.NoArgsConstructor; +/** + * Represents a signup request named {@link SignupRequest}. + */ @Data @AllArgsConstructor @NoArgsConstructor diff --git a/src/main/java/com/project/parkinglot/payload/request/auth/TokenRefreshRequest.java b/src/main/java/com/project/parkinglot/payload/request/auth/TokenRefreshRequest.java index ac83b59..d1a2d51 100644 --- a/src/main/java/com/project/parkinglot/payload/request/auth/TokenRefreshRequest.java +++ b/src/main/java/com/project/parkinglot/payload/request/auth/TokenRefreshRequest.java @@ -6,6 +6,9 @@ import lombok.Data; import lombok.NoArgsConstructor; +/** + * Represents a token refresh request named {@link TokenRefreshRequest}. + */ @Data @AllArgsConstructor @NoArgsConstructor diff --git a/src/main/java/com/project/parkinglot/payload/response/CustomPageResponse.java b/src/main/java/com/project/parkinglot/payload/response/CustomPageResponse.java index 105de5f..300279f 100644 --- a/src/main/java/com/project/parkinglot/payload/response/CustomPageResponse.java +++ b/src/main/java/com/project/parkinglot/payload/response/CustomPageResponse.java @@ -6,6 +6,10 @@ import java.util.List; +/** + * Represents a custom page response. + * @param the type of content in the response. + */ @Getter @Builder public class CustomPageResponse { @@ -21,6 +25,13 @@ public class CustomPageResponse { private Long totalElementCount; + /** + * Creates a custom page response from a Spring Data {@link Page} object. + * + * @param page the Page object + * @param the type of content in the page + * @return a CustomPageResponse object + */ public static CustomPageResponse of(Page page) { return CustomPageResponse.builder() .content(page.getContent()) diff --git a/src/main/java/com/project/parkinglot/payload/response/CustomResponse.java b/src/main/java/com/project/parkinglot/payload/response/CustomResponse.java index c33c5c5..2b54ab2 100644 --- a/src/main/java/com/project/parkinglot/payload/response/CustomResponse.java +++ b/src/main/java/com/project/parkinglot/payload/response/CustomResponse.java @@ -12,6 +12,10 @@ import java.time.LocalDateTime; +/** + * Represents a custom response. + * @param the type of the response + */ @Getter @Setter @Builder @@ -40,6 +44,13 @@ public CustomResponse(@Nullable T response, @Nonnull HttpStatus status) { .build(); + /** + * Creates a successful response with the given response body. + * + * @param response the response body + * @param the type of the response body + * @return a CustomResponse object + */ public static CustomResponse ok(E response) { return CustomResponse.builder() .response(response) @@ -48,6 +59,13 @@ public static CustomResponse ok(E response) { .build(); } + /** + * Creates a successful response with the given response body and HTTP status CREATED. + * + * @param response the response body + * @param the type of the response body + * @return a CustomResponse object + */ @ResponseStatus(HttpStatus.CREATED) public static CustomResponse created(E response) { return CustomResponse.builder() @@ -56,4 +74,5 @@ public static CustomResponse created(E response) { .httpStatus(HttpStatus.CREATED) .build(); } + } diff --git a/src/main/java/com/project/parkinglot/payload/response/ErrorResponse.java b/src/main/java/com/project/parkinglot/payload/response/ErrorResponse.java index 8695864..8aa4b1c 100644 --- a/src/main/java/com/project/parkinglot/payload/response/ErrorResponse.java +++ b/src/main/java/com/project/parkinglot/payload/response/ErrorResponse.java @@ -10,6 +10,9 @@ import java.time.LocalDateTime; import java.util.List; +/** + * Represents an error response named {@link ErrorResponse}. + */ @Data @AllArgsConstructor @NoArgsConstructor diff --git a/src/main/java/com/project/parkinglot/payload/response/auth/JWTResponse.java b/src/main/java/com/project/parkinglot/payload/response/auth/JWTResponse.java index 5b4ebcf..bcb1561 100644 --- a/src/main/java/com/project/parkinglot/payload/response/auth/JWTResponse.java +++ b/src/main/java/com/project/parkinglot/payload/response/auth/JWTResponse.java @@ -5,6 +5,9 @@ import lombok.Data; import lombok.NoArgsConstructor; +/** + * Represents a JWT response named {@link JWTResponse}. + */ @Data @Builder @NoArgsConstructor diff --git a/src/main/java/com/project/parkinglot/payload/response/auth/TokenRefreshResponse.java b/src/main/java/com/project/parkinglot/payload/response/auth/TokenRefreshResponse.java index 4d132ec..e9a9642 100644 --- a/src/main/java/com/project/parkinglot/payload/response/auth/TokenRefreshResponse.java +++ b/src/main/java/com/project/parkinglot/payload/response/auth/TokenRefreshResponse.java @@ -5,6 +5,9 @@ import lombok.Data; import lombok.NoArgsConstructor; +/** + * Represents a token refresh response named {@link TokenRefreshResponse}. + */ @Data @Builder @NoArgsConstructor diff --git a/src/main/java/com/project/parkinglot/repository/ParkRepository.java b/src/main/java/com/project/parkinglot/repository/ParkRepository.java index a8e639f..9aa5be6 100644 --- a/src/main/java/com/project/parkinglot/repository/ParkRepository.java +++ b/src/main/java/com/project/parkinglot/repository/ParkRepository.java @@ -8,13 +8,30 @@ import java.util.Optional; +/** + * Repository interface named {@link ParkRepository} for managing park records. + */ public interface ParkRepository extends JpaRepository { + /** + * Counts park records by parking area and park status. + * + * @param parkingArea the parking area + * @param parkStatus the park status + * @return the count of park records + */ Integer countByParkingAreaEntityAndParkStatus( final ParkingAreaEntity parkingArea, final ParkStatus parkStatus ); + /** + * Finds the latest park record by vehicle and park status. + * + * @param vehicle the vehicle + * @param parkStatus the park status + * @return the latest park record + */ Optional findTopByVehicleEntityAndParkStatusOrderByCheckInDesc( final VehicleEntity vehicle, final ParkStatus parkStatus diff --git a/src/main/java/com/project/parkinglot/repository/ParkingAreaRepository.java b/src/main/java/com/project/parkinglot/repository/ParkingAreaRepository.java index dc53362..dec9cbf 100644 --- a/src/main/java/com/project/parkinglot/repository/ParkingAreaRepository.java +++ b/src/main/java/com/project/parkinglot/repository/ParkingAreaRepository.java @@ -9,21 +9,50 @@ import java.time.LocalDate; import java.util.Optional; +/** + * Repository interface named {@link ParkingAreaRepository} for managing parking areas. + */ public interface ParkingAreaRepository extends JpaRepository { + /** + * Checks if a parking area with the given name exists. + * + * @param name the name of the parking area + * @return true if the parking area exists, false otherwise + */ boolean existsByName( final String name ); + /** + * Checks if a parking area exists by name and location. + * + * @param name the name of the parking area + * @param location the location of the parking area + * @return true if the parking area exists, false otherwise + */ boolean existsParkingAreaEntitiesByNameAndLocation( final String name, final String location ); + /** + * Finds a parking area by name. + * + * @param name the name of the parking area + * @return the parking area if found, otherwise empty + */ Optional findByName( final String name ); + /** + * Calculates the daily income of a parking area. + * + * @param date the date for which to calculate income + * @param parkingAreaId the ID of the parking area + * @return the total income of the parking area for the given date + */ @Query( value = "SELECT SUM(park.TOTAL_COST) FROM parking_area " + "LEFT JOIN park " + diff --git a/src/main/java/com/project/parkinglot/repository/PriceListRepository.java b/src/main/java/com/project/parkinglot/repository/PriceListRepository.java index b0485e1..06cf99a 100644 --- a/src/main/java/com/project/parkinglot/repository/PriceListRepository.java +++ b/src/main/java/com/project/parkinglot/repository/PriceListRepository.java @@ -3,5 +3,8 @@ import com.project.parkinglot.model.entity.PriceListEntity; import org.springframework.data.jpa.repository.JpaRepository; +/** + * Repository interface named {@link PriceListRepository} for managing price lists. + */ public interface PriceListRepository extends JpaRepository { } diff --git a/src/main/java/com/project/parkinglot/repository/PriceRepository.java b/src/main/java/com/project/parkinglot/repository/PriceRepository.java index 32d3f4f..097f357 100644 --- a/src/main/java/com/project/parkinglot/repository/PriceRepository.java +++ b/src/main/java/com/project/parkinglot/repository/PriceRepository.java @@ -3,6 +3,9 @@ import com.project.parkinglot.model.entity.PriceEntity; import org.springframework.data.jpa.repository.JpaRepository; +/** + * Repository interface named {@link PriceRepository} for managing prices. + */ public interface PriceRepository extends JpaRepository { } diff --git a/src/main/java/com/project/parkinglot/repository/VehicleRepository.java b/src/main/java/com/project/parkinglot/repository/VehicleRepository.java index eb0a8c8..03ec047 100644 --- a/src/main/java/com/project/parkinglot/repository/VehicleRepository.java +++ b/src/main/java/com/project/parkinglot/repository/VehicleRepository.java @@ -5,12 +5,27 @@ import java.util.Optional; +/** + * Repository interface named {@link VehicleRepository} for managing vehicles. + */ public interface VehicleRepository extends JpaRepository { + /** + * Checks if a vehicle exists by license plate. + * + * @param licensePlate the license plate of the vehicle + * @return true if the vehicle exists, false otherwise + */ Boolean existsByLicensePlate( final String licensePlate ); + /** + * Finds a vehicle by license plate. + * + * @param licensePlate the license plate of the vehicle + * @return the vehicle if found, otherwise empty + */ Optional findByLicensePlate(String licensePlate); } diff --git a/src/main/java/com/project/parkinglot/security/CustomUserDetails.java b/src/main/java/com/project/parkinglot/security/CustomUserDetails.java index 8baa816..d5e3cc7 100644 --- a/src/main/java/com/project/parkinglot/security/CustomUserDetails.java +++ b/src/main/java/com/project/parkinglot/security/CustomUserDetails.java @@ -12,6 +12,9 @@ import java.util.Collections; import java.util.Map; +/** + * Custom implementation of UserDetails named {@link CustomUserDetails} of Spring Security UserDetails. + */ @Getter @RequiredArgsConstructor public class CustomUserDetails implements UserDetails { @@ -21,49 +24,99 @@ public class CustomUserDetails implements UserDetails { private final UserEntity userEntity; + /** + * Retrieves the authorities granted to the user. + * + * @return A collection of granted authorities. + */ @Override public Collection getAuthorities() { return Collections.singleton(new SimpleGrantedAuthority(userEntity.getRole().name())); } + /** + * Retrieves the password used to authenticate the user. + * + * @return The password. + */ @Override public String getPassword() { return userEntity.getPassword(); } + /** + * Retrieves the username used to authenticate the user. + * + * @return The username. + */ @Override public String getUsername() { return userEntity.getUsername(); } + /** + * Indicates whether the user's account has expired. + * + * @return Always returns true. + */ @Override public boolean isAccountNonExpired() { return true; } + /** + * Indicates whether the user is locked or unlocked. + * + * @return Always returns true. + */ @Override public boolean isAccountNonLocked() { return true; } + /** + * Indicates whether the user's credentials (password) has expired. + * + * @return Always returns true. + */ @Override public boolean isCredentialsNonExpired() { return true; } + /** + * Indicates whether the user is enabled or disabled. + * + * @return Always returns true. + */ @Override public boolean isEnabled() { return true; } + /** + * Retrieves the user's email. + * + * @return The user's email. + */ public String getEmail() { return userEntity.getEmail(); } + /** + * Retrieves the user's ID. + * + * @return The user's ID. + */ public String getId() { return userEntity.getId(); } + /** + * Retrieves the user's claims. + * + * @return A map containing the user's claims. + */ public Map getClaims() { return userEntity.getClaims(); } diff --git a/src/main/java/com/project/parkinglot/security/CustomUserDetailsService.java b/src/main/java/com/project/parkinglot/security/CustomUserDetailsService.java index cac663c..0da7174 100644 --- a/src/main/java/com/project/parkinglot/security/CustomUserDetailsService.java +++ b/src/main/java/com/project/parkinglot/security/CustomUserDetailsService.java @@ -8,12 +8,22 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Service; +/** + * Service class named {@link CustomUserDetailsService} for loading user-specific data. + */ @Service @RequiredArgsConstructor public class CustomUserDetailsService implements UserDetailsService { private final UserService userService; + /** + * Locates the user based on the username. + * + * @param username the username identifying the user whose data is required. + * @return a fully populated user record. + * @throws UsernameNotFoundException if the user could not be found or the user has no GrantedAuthority. + */ @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { diff --git a/src/main/java/com/project/parkinglot/security/jwt/AuthEntryPointJwt.java b/src/main/java/com/project/parkinglot/security/jwt/AuthEntryPointJwt.java index f5e3809..7654823 100644 --- a/src/main/java/com/project/parkinglot/security/jwt/AuthEntryPointJwt.java +++ b/src/main/java/com/project/parkinglot/security/jwt/AuthEntryPointJwt.java @@ -15,12 +15,23 @@ import java.util.HashMap; import java.util.Map; +/** + * Custom authentication entry point named {@link AuthEntryPointJwt} for handling unauthorized requests. + */ @Component public class AuthEntryPointJwt implements AuthenticationEntryPoint { private static final Logger LOGGER = LoggerFactory.getLogger(AuthEntryPointJwt.class); - + /** + * Commences the authentication process for unauthorized requests. + * + * @param request The request object. + * @param response The response object. + * @param authException The authentication exception. + * @throws IOException If an I/O error occurs. + * @throws ServletException If a servlet exception occurs. + */ @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { diff --git a/src/main/java/com/project/parkinglot/security/jwt/AuthTokenFilter.java b/src/main/java/com/project/parkinglot/security/jwt/AuthTokenFilter.java index a272b29..4b60907 100644 --- a/src/main/java/com/project/parkinglot/security/jwt/AuthTokenFilter.java +++ b/src/main/java/com/project/parkinglot/security/jwt/AuthTokenFilter.java @@ -17,6 +17,9 @@ import java.io.IOException; +/** + * Authentication Token Filter named {@link AuthTokenFilter} for validating JWT tokens. + */ @RequiredArgsConstructor @Log4j2 public class AuthTokenFilter extends OncePerRequestFilter { @@ -25,6 +28,15 @@ public class AuthTokenFilter extends OncePerRequestFilter { private final CustomUserDetailsService customUserDetailsService; + /** + * Filters incoming requests. + * + * @param request The incoming request. + * @param response The response to be generated. + * @param filterChain The chain of filters to proceed the request. + * @throws ServletException If a servlet error occurs. + * @throws IOException If an input or output error occurs. + */ @Override protected void doFilterInternal( @NonNull HttpServletRequest request, @@ -55,6 +67,12 @@ protected void doFilterInternal( filterChain.doFilter(request, response); } + /** + * Parses JWT token from the request header. + * + * @param request The incoming HTTP request. + * @return JWT token if exists, otherwise null. + */ private String parseJwt(HttpServletRequest request) { String headerAuth = request.getHeader("Authorization"); diff --git a/src/main/java/com/project/parkinglot/security/jwt/JwtUtils.java b/src/main/java/com/project/parkinglot/security/jwt/JwtUtils.java index fe29bdd..26b0f8d 100644 --- a/src/main/java/com/project/parkinglot/security/jwt/JwtUtils.java +++ b/src/main/java/com/project/parkinglot/security/jwt/JwtUtils.java @@ -14,6 +14,9 @@ import java.util.Date; import java.util.Map; +/** + * Utility class named {@link JwtUtils} for JWT operations. + */ @Component @Log4j2 public class JwtUtils { @@ -24,12 +27,25 @@ public class JwtUtils { @Value("${jwt.expireMs}") private int jwtExpirationMs; + /** + * Generates JWT token. + * + * @param auth The authentication object. + * @return Generated JWT token. + */ public String generateJwtToken(Authentication auth) { CustomUserDetails userDetails = (CustomUserDetails) auth.getPrincipal(); Map claims = userDetails.getClaims(); return createToken(claims, userDetails.getUsername()); } + /** + * Creates JWT token. + * + * @param claims The claims to be included in the token. + * @param subject The subject of the token. + * @return Generated JWT token. + */ public String createToken(Map claims, String subject) { Date now = new Date(); Date expirationDate = new Date(now.getTime() + jwtExpirationMs); @@ -43,17 +59,34 @@ public String createToken(Map claims, String subject) { .compact(); } + /** + * Generates JWT token for a custom user. + * + * @param customUserDetails The custom user details. + * @return Generated JWT token. + */ public String generateJwtToken(CustomUserDetails customUserDetails) { Map claims = customUserDetails.getClaims(); claims.put(TokenClaims.ID.getValue(), customUserDetails.getId()); return createToken(claims, customUserDetails.getUsername()); } + /** + * Retrieves the signing key from the JWT secret. + * + * @return The signing key. + */ private Key getSignInKey() { byte[] keyBytes = Decoders.BASE64.decode(jwtSecret); return Keys.hmacShaKeyFor(keyBytes); } + /** + * Extracts claims from JWT token. + * + * @param token The JWT token. + * @return Claims extracted from the token. + */ public Claims extractClaims(String token) { return Jwts.parserBuilder() .setSigningKey(getSignInKey()) @@ -62,15 +95,33 @@ public Claims extractClaims(String token) { .getBody(); } + /** + * Extracts user ID from JWT token. + * + * @param token The JWT token. + * @return Extracted user ID. + */ public String getIdFromToken(String token) { String idValue = extractClaims(token).get(TokenClaims.ID.getValue()).toString(); return idValue; } + /** + * Extracts user email from JWT token. + * + * @param token The JWT token. + * @return Extracted user email. + */ public String getEmailFromToken(String token) { return extractClaims(token).get(TokenClaims.EMAIL.getValue()).toString(); } + /** + * Validates JWT token. + * + * @param authToken The JWT token. + * @return True if the token is valid, otherwise false. + */ public boolean validateJwtToken(String authToken) { log.info("JwtUtils | validateJwtToken | authToken: {}", authToken); @@ -91,6 +142,12 @@ public boolean validateJwtToken(String authToken) { return false; } + /** + * Extracts JWT token from the authorization header. + * + * @param authorizationHeader The authorization header. + * @return Extracted JWT token. + */ public String extractTokenFromHeader(String authorizationHeader) { if (authorizationHeader != null && authorizationHeader.startsWith("Bearer ")) { diff --git a/src/main/java/com/project/parkinglot/security/model/entity/RefreshToken.java b/src/main/java/com/project/parkinglot/security/model/entity/RefreshToken.java index cbcae27..7e1af55 100644 --- a/src/main/java/com/project/parkinglot/security/model/entity/RefreshToken.java +++ b/src/main/java/com/project/parkinglot/security/model/entity/RefreshToken.java @@ -8,6 +8,9 @@ import java.time.LocalDate; +/** + * Represents a refresh token entity named {@link RefreshToken}. + */ @Entity @Data @Builder diff --git a/src/main/java/com/project/parkinglot/security/model/entity/UserEntity.java b/src/main/java/com/project/parkinglot/security/model/entity/UserEntity.java index 094701f..2a9729a 100644 --- a/src/main/java/com/project/parkinglot/security/model/entity/UserEntity.java +++ b/src/main/java/com/project/parkinglot/security/model/entity/UserEntity.java @@ -13,6 +13,9 @@ import java.util.List; import java.util.Map; +/** + * Represents a user entity named {@link UserEntity}. + */ @Entity @Data @Builder @@ -48,6 +51,11 @@ public class UserEntity { ) private List vehicles; + /** + * Generates JWT claims for the user. + * + * @return Map of JWT claims. + */ public Map getClaims() { final Map claims = new HashMap<>(); claims.put(TokenClaims.ID.getValue(), this.id); diff --git a/src/main/java/com/project/parkinglot/security/model/enums/Role.java b/src/main/java/com/project/parkinglot/security/model/enums/Role.java index 16bba8c..747bac2 100644 --- a/src/main/java/com/project/parkinglot/security/model/enums/Role.java +++ b/src/main/java/com/project/parkinglot/security/model/enums/Role.java @@ -3,6 +3,9 @@ import lombok.Getter; import lombok.RequiredArgsConstructor; +/** + * Enumerator class named {@link Role} representing user roles. + */ @Getter @RequiredArgsConstructor public enum Role { diff --git a/src/main/java/com/project/parkinglot/security/model/enums/TokenClaims.java b/src/main/java/com/project/parkinglot/security/model/enums/TokenClaims.java index 9a4bcab..8a90b96 100644 --- a/src/main/java/com/project/parkinglot/security/model/enums/TokenClaims.java +++ b/src/main/java/com/project/parkinglot/security/model/enums/TokenClaims.java @@ -3,6 +3,9 @@ import lombok.Getter; import lombok.RequiredArgsConstructor; +/** + * Enumerator class named {@link TokenClaims} representing claims in JWT tokens. + */ @Getter @RequiredArgsConstructor public enum TokenClaims { diff --git a/src/main/java/com/project/parkinglot/security/repository/RefreshTokenRepository.java b/src/main/java/com/project/parkinglot/security/repository/RefreshTokenRepository.java index df37c4c..ea6c616 100644 --- a/src/main/java/com/project/parkinglot/security/repository/RefreshTokenRepository.java +++ b/src/main/java/com/project/parkinglot/security/repository/RefreshTokenRepository.java @@ -7,13 +7,33 @@ import java.util.Optional; - +/** + * Repository interface named {@link RefreshTokenRepository} for managing refresh tokens. + */ public interface RefreshTokenRepository extends JpaRepository { + /** + * Find a refresh token by user ID. + * + * @param userId The ID of the user. + * @return The refresh token. + */ RefreshToken findByUserEntityId(String userId); + /** + * Find a refresh token by its token string. + * + * @param token The token string. + * @return The refresh token. + */ Optional findByToken(String token); + /** + * Delete refresh tokens associated with a user entity. + * + * @param userEntity The user entity. + * @return The number of tokens deleted. + */ @Modifying int deleteByUserEntity(UserEntity userEntity); diff --git a/src/main/java/com/project/parkinglot/security/repository/UserRepository.java b/src/main/java/com/project/parkinglot/security/repository/UserRepository.java index 723e8fc..0646c53 100644 --- a/src/main/java/com/project/parkinglot/security/repository/UserRepository.java +++ b/src/main/java/com/project/parkinglot/security/repository/UserRepository.java @@ -5,13 +5,33 @@ import java.util.Optional; - +/** + * Repository interface named {@link UserRepository} for managing user entities. + */ public interface UserRepository extends JpaRepository { + /** + * Check if a user with a given email exists. + * + * @param email The email to check. + * @return True if the user exists, false otherwise. + */ boolean existsByEmail(String email); + /** + * Find a user by their username. + * + * @param username The username. + * @return The user entity. + */ Optional findByUsername(String username); + /** + * Find a user by their email. + * + * @param email The email. + * @return The user entity. + */ Optional findByEmail(String email); } diff --git a/src/main/java/com/project/parkinglot/service/auth/AuthService.java b/src/main/java/com/project/parkinglot/service/auth/AuthService.java index f25142d..2f48c56 100644 --- a/src/main/java/com/project/parkinglot/service/auth/AuthService.java +++ b/src/main/java/com/project/parkinglot/service/auth/AuthService.java @@ -6,14 +6,41 @@ import com.project.parkinglot.payload.response.auth.JWTResponse; import com.project.parkinglot.payload.response.auth.TokenRefreshResponse; +/** + * Service interface named {@link AuthService} for user authentication. + */ public interface AuthService { + /** + * Registers a new user. + * + * @param request the signup request + * @return the generated user ID + */ String register(SignupRequest request); + /** + * Authenticates a user. + * + * @param request the login request + * @return the JWT response + */ JWTResponse login(LoginRequest request); + /** + * Refreshes the JWT token. + * + * @param request the token refresh request + * @return the token refresh response + */ TokenRefreshResponse refreshToken(TokenRefreshRequest request); + /** + * Logs out the user. + * + * @param token the user's token + * @return the result of the logout operation + */ String logout(String token); } diff --git a/src/main/java/com/project/parkinglot/service/auth/RefreshTokenService.java b/src/main/java/com/project/parkinglot/service/auth/RefreshTokenService.java index b8e3180..3f34614 100644 --- a/src/main/java/com/project/parkinglot/service/auth/RefreshTokenService.java +++ b/src/main/java/com/project/parkinglot/service/auth/RefreshTokenService.java @@ -5,16 +5,49 @@ import java.util.Optional; +/** + * Service interface named {@link RefreshTokenService} for managing refresh tokens. + */ public interface RefreshTokenService { + /** + * Creates a refresh token for the specified user. + * + * @param userEntity the user entity + * @return the generated refresh token + */ String createRefreshToken(UserEntity userEntity); + /** + * Checks if the refresh token is expired. + * + * @param token the refresh token + * @return {@code true} if the token is expired, {@code false} otherwise + */ boolean isRefreshExpired(RefreshToken token); + /** + * Retrieves the refresh token associated with the specified user. + * + * @param userId the user ID + * @return the refresh token + */ RefreshToken getByUser(String userId); + /** + * Retrieves the refresh token by its token value. + * + * @param token the token value + * @return an {@link Optional} containing the refresh token, or empty if not found + */ Optional findByToken(String token); + /** + * Deletes the refresh token associated with the specified user. + * + * @param userId the user ID + * @return the number of refresh tokens deleted + */ int deleteByUserId(String userId); } diff --git a/src/main/java/com/project/parkinglot/service/auth/UserService.java b/src/main/java/com/project/parkinglot/service/auth/UserService.java index 337e998..dbf2863 100644 --- a/src/main/java/com/project/parkinglot/service/auth/UserService.java +++ b/src/main/java/com/project/parkinglot/service/auth/UserService.java @@ -4,12 +4,33 @@ import java.util.Optional; +/** + * Service interface named {@link UserService} for user-related operations. + */ public interface UserService { + /** + * Retrieves a user by username. + * + * @param username the username + * @return an {@link Optional} containing the user, or empty if not found + */ Optional findByUsername(String username); + /** + * Retrieves a user by ID. + * + * @param userId the user ID + * @return an {@link Optional} containing the user, or empty if not found + */ Optional findById(String userId); + /** + * Retrieves a user by email. + * + * @param email the email address + * @return an {@link Optional} containing the user, or empty if not found + */ Optional findByEmail(String email); } diff --git a/src/main/java/com/project/parkinglot/service/auth/impl/AuthServiceImpl.java b/src/main/java/com/project/parkinglot/service/auth/impl/AuthServiceImpl.java index 58084b5..786e672 100644 --- a/src/main/java/com/project/parkinglot/service/auth/impl/AuthServiceImpl.java +++ b/src/main/java/com/project/parkinglot/service/auth/impl/AuthServiceImpl.java @@ -23,6 +23,9 @@ import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; +/** + * Service class named {@link AuthServiceImpl} that provides authentication-related functionalities. + */ @Service @RequiredArgsConstructor public class AuthServiceImpl implements AuthService { @@ -37,7 +40,12 @@ public class AuthServiceImpl implements AuthService { private final JwtUtils jwtUtils; - + /** + * Registers a new user. + * + * @param request the signup request + * @return the generated user ID + */ @Override public String register(SignupRequest request) { @@ -58,7 +66,12 @@ public String register(SignupRequest request) { return "Success"; } - + /** + * Authenticates a user. + * + * @param request the login request + * @return the JWT response + */ @Override public JWTResponse login(LoginRequest request) { @@ -78,7 +91,12 @@ public JWTResponse login(LoginRequest request) { .build(); } - + /** + * Refreshes the JWT token. + * + * @param request the token refresh request + * @return the token refresh response + */ @Override public TokenRefreshResponse refreshToken(TokenRefreshRequest request) { @@ -99,6 +117,12 @@ public TokenRefreshResponse refreshToken(TokenRefreshRequest request) { return null; } + /** + * Logs out the user. + * + * @param token the user's token + * @return the result of the logout operation + */ @Override public String logout(String token) { diff --git a/src/main/java/com/project/parkinglot/service/auth/impl/RefreshTokenServiceImpl.java b/src/main/java/com/project/parkinglot/service/auth/impl/RefreshTokenServiceImpl.java index 7d62c06..84772b9 100644 --- a/src/main/java/com/project/parkinglot/service/auth/impl/RefreshTokenServiceImpl.java +++ b/src/main/java/com/project/parkinglot/service/auth/impl/RefreshTokenServiceImpl.java @@ -17,6 +17,9 @@ import java.util.Optional; import java.util.UUID; +/** + * Service class named {@link RefreshTokenServiceImpl} that provides refresh token-related functionalities. + */ @Service @RequiredArgsConstructor public class RefreshTokenServiceImpl implements RefreshTokenService { @@ -28,7 +31,12 @@ public class RefreshTokenServiceImpl implements RefreshTokenService { private final UserService userService; - + /** + * Creates a refresh token for the specified user. + * + * @param userEntity the user entity + * @return the generated refresh token + */ @Override public String createRefreshToken(UserEntity userEntity) { @@ -46,23 +54,45 @@ public String createRefreshToken(UserEntity userEntity) { return token.getToken(); } + /** + * Checks if the refresh token is expired. + * + * @param token the refresh token + * @return {@code true} if the token is expired, {@code false} otherwise + */ @Override public boolean isRefreshExpired(RefreshToken token) { return token.getExpiryDate().isBefore(LocalDate.now()); } + /** + * Retrieves the refresh token associated with the specified user. + * + * @param userId the user ID + * @return the refresh token + */ @Override public RefreshToken getByUser(String userId) { return refreshTokenRepository.findByUserEntityId(userId); } - + /** + * Retrieves the refresh token by its token value. + * + * @param token the token value + * @return an {@link Optional} containing the refresh token, or empty if not found + */ @Override public Optional findByToken(String token) { return refreshTokenRepository.findByToken(token); } - + /** + * Deletes the refresh token associated with the specified user. + * + * @param userId the user ID + * @return the number of refresh tokens deleted + */ @Override @Transactional public int deleteByUserId(String userId) { diff --git a/src/main/java/com/project/parkinglot/service/auth/impl/UserServiceImpl.java b/src/main/java/com/project/parkinglot/service/auth/impl/UserServiceImpl.java index 5732452..595091d 100644 --- a/src/main/java/com/project/parkinglot/service/auth/impl/UserServiceImpl.java +++ b/src/main/java/com/project/parkinglot/service/auth/impl/UserServiceImpl.java @@ -8,22 +8,43 @@ import java.util.Optional; +/** + * Service class named {@link UserServiceImpl} that provides user-related functionalities. + */ @Service @RequiredArgsConstructor public class UserServiceImpl implements UserService { private final UserRepository userRepository; + /** + * Retrieves a user by username. + * + * @param username the username + * @return an {@link Optional} containing the user, or empty if not found + */ @Override public Optional findByUsername(String username) { return userRepository.findByUsername(username); } + /** + * Retrieves a user by ID. + * + * @param userId the user ID + * @return an {@link Optional} containing the user, or empty if not found + */ @Override public Optional findById(String userId) { return userRepository.findById(userId); } + /** + * Retrieves a user by email. + * + * @param email the email address + * @return an {@link Optional} containing the user, or empty if not found + */ @Override public Optional findByEmail(String email) { return userRepository.findByEmail(email); diff --git a/src/main/java/com/project/parkinglot/service/park/ParkService.java b/src/main/java/com/project/parkinglot/service/park/ParkService.java index 2d14a12..b7d0352 100644 --- a/src/main/java/com/project/parkinglot/service/park/ParkService.java +++ b/src/main/java/com/project/parkinglot/service/park/ParkService.java @@ -6,12 +6,35 @@ import com.project.parkinglot.model.dto.response.park.ParkCheckOutResponse; import com.project.parkinglot.model.entity.ParkingAreaEntity; +/** + * Service interface named {@link ParkService} for managing park operations. + */ public interface ParkService { + /** + * Checks in a vehicle to the parking area. + * + * @param userId the ID of the user + * @param requestBody the check-in request body + * @return the check-in response + */ ParkCheckInResponse checkIn(final String userId, final ParkCheckInRequest requestBody); + /** + * Counts the number of current parks in the parking area. + * + * @param parkingAreaEntity the parking area entity + * @return the number of current parks + */ Integer countCurrentParks(ParkingAreaEntity parkingAreaEntity); + /** + * Checks out a vehicle from the parking area. + * + * @param userId the ID of the user + * @param parkCheckOutRequest the check-out request + * @return the check-out response + */ ParkCheckOutResponse checkOut( final String userId, final ParkCheckOutRequest parkCheckOutRequest diff --git a/src/main/java/com/project/parkinglot/service/park/impl/ParkServiceImpl.java b/src/main/java/com/project/parkinglot/service/park/impl/ParkServiceImpl.java index d0b4eb4..5be44ca 100644 --- a/src/main/java/com/project/parkinglot/service/park/impl/ParkServiceImpl.java +++ b/src/main/java/com/project/parkinglot/service/park/impl/ParkServiceImpl.java @@ -28,6 +28,9 @@ import java.math.BigDecimal; import java.time.LocalDateTime; +/** + * Service implementation class named {@link ParkServiceImpl} for managing park operations. + */ @Service @RequiredArgsConstructor public class ParkServiceImpl implements ParkService { @@ -52,6 +55,13 @@ public class ParkServiceImpl implements ParkService { private final ParkEntityToParkCheckOutResponseMapper parkEntityToParkCheckOutResponseMapper = ParkEntityToParkCheckOutResponseMapper.initialize(); + /** + * Checks in a vehicle to the parking area. + * + * @param userId the ID of the user + * @param parkCheckInRequest the check-in request + * @return the check-in response + */ @Override @Transactional public ParkCheckInResponse checkIn(final String userId, final ParkCheckInRequest parkCheckInRequest) { @@ -65,6 +75,13 @@ public ParkCheckInResponse checkIn(final String userId, final ParkCheckInRequest return parkToParkCheckInResponseMapper.map(park); } + /** + * Checks out a vehicle from the parking area. + * + * @param userId the ID of the user + * @param parkCheckOutRequest the check-out request + * @return the check-out response + */ @Override @Transactional public ParkCheckOutResponse checkOut( @@ -107,11 +124,25 @@ public ParkCheckOutResponse checkOut( return parkEntityToParkCheckOutResponseMapper.map(parkEntity); } + /** + * Counts the number of current parks in the parking area. + * + * @param parkingAreaEntity the parking area entity + * @return the number of current parks + */ @Override public Integer countCurrentParks(ParkingAreaEntity parkingAreaEntity) { return parkRepository.countByParkingAreaEntityAndParkStatus(parkingAreaEntity, ParkStatus.EMPTY); } + /** + * Parks a vehicle in the available parking area. + * + * @param checkInRequest the check-in request + * @param vehicle the vehicle to be parked + * @param existingParkingEntityArea the existing parking area entity + * @return the parked vehicle + */ private Park parkAvailableArea(ParkCheckInRequest checkInRequest, Vehicle vehicle, ParkingAreaEntity existingParkingEntityArea) { ParkEntity parkEntity = parkCheckInRequestToParkEntityMapper.map(checkInRequest); parkEntity.setVehicleEntity(vehicleToVehicleEntityMapper.map(vehicle)); @@ -122,6 +153,12 @@ private Park parkAvailableArea(ParkCheckInRequest checkInRequest, Vehicle vehicl return parkEntityToParkMapper.map(savedParkEntity); } + /** + * Validates the available capacity in the parking area. + * + * @param parkingAreaEntity the parking area entity to check + * @throws ParkingAreaCapacityException if the parking area capacity is full + */ private void validateAvailableCapacity(ParkingAreaEntity parkingAreaEntity) { Integer currentParks = countCurrentParks(parkingAreaEntity); if (parkingAreaEntity.getCapacity() <= currentParks) { diff --git a/src/main/java/com/project/parkinglot/service/parking_area/ParkingAreaCreateService.java b/src/main/java/com/project/parkinglot/service/parking_area/ParkingAreaCreateService.java index 79eea0c..d52b091 100644 --- a/src/main/java/com/project/parkinglot/service/parking_area/ParkingAreaCreateService.java +++ b/src/main/java/com/project/parkinglot/service/parking_area/ParkingAreaCreateService.java @@ -3,8 +3,17 @@ import com.project.parkinglot.model.ParkingArea; import com.project.parkinglot.model.dto.request.parking_area.ParkingAreaCreateRequest; +/** + * Service interface named {@link ParkingAreaCreateService} for creating parking areas. + */ public interface ParkingAreaCreateService { + /** + * Creates a new parking area. + * + * @param parkingAreaCreateRequest the request containing details for creating the parking area + * @return the created parking area + */ ParkingArea createParkingArea( final ParkingAreaCreateRequest parkingAreaCreateRequest ); diff --git a/src/main/java/com/project/parkinglot/service/parking_area/ParkingAreaDeleteService.java b/src/main/java/com/project/parkinglot/service/parking_area/ParkingAreaDeleteService.java index ab0b78d..2eca477 100644 --- a/src/main/java/com/project/parkinglot/service/parking_area/ParkingAreaDeleteService.java +++ b/src/main/java/com/project/parkinglot/service/parking_area/ParkingAreaDeleteService.java @@ -1,7 +1,15 @@ package com.project.parkinglot.service.parking_area; +/** + * Service interface named {@link ParkingAreaDeleteService} for deleting parking areas. + */ public interface ParkingAreaDeleteService { + /** + * Deletes a parking area by its ID. + * + * @param parkingAreaId the ID of the parking area to delete + */ void deleteParkingAreaById( final String parkingAreaId ); diff --git a/src/main/java/com/project/parkinglot/service/parking_area/ParkingAreaGetService.java b/src/main/java/com/project/parkinglot/service/parking_area/ParkingAreaGetService.java index 074f3ac..0e2cd20 100644 --- a/src/main/java/com/project/parkinglot/service/parking_area/ParkingAreaGetService.java +++ b/src/main/java/com/project/parkinglot/service/parking_area/ParkingAreaGetService.java @@ -5,12 +5,34 @@ import java.time.LocalDate; +/** + * Service interface named {@link ParkingAreaGetService} for retrieving parking areas. + */ public interface ParkingAreaGetService { + /** + * Retrieves a parking area by its ID. + * + * @param parkingAreaId the ID of the parking area to retrieve + * @return the retrieved parking area + */ ParkingArea getParkingAreaById(final String parkingAreaId); + /** + * Retrieves a parking area by its name. + * + * @param name the name of the parking area to retrieve + * @return the retrieved parking area + */ ParkingArea getParkingAreaByName(final String name); + /** + * Retrieves daily income for a parking area on a given date. + * + * @param date the date for which to retrieve income + * @param parkingAreaId the ID of the parking area + * @return the daily income of the parking area + */ ParkingAreaIncomeResponse getDailyIncome(final LocalDate date, final String parkingAreaId); } diff --git a/src/main/java/com/project/parkinglot/service/parking_area/ParkingAreaUpdateService.java b/src/main/java/com/project/parkinglot/service/parking_area/ParkingAreaUpdateService.java index 41b164f..efb9ff4 100644 --- a/src/main/java/com/project/parkinglot/service/parking_area/ParkingAreaUpdateService.java +++ b/src/main/java/com/project/parkinglot/service/parking_area/ParkingAreaUpdateService.java @@ -3,9 +3,21 @@ import com.project.parkinglot.model.ParkingArea; import com.project.parkinglot.model.dto.request.parking_area.ParkingAreaUpdateRequest; +/** + * Service interface named {@link ParkingAreaUpdateService} for updating parking areas. + */ public interface ParkingAreaUpdateService { + + /** + * Updates the capacity of a parking area. + * + * @param parkingAreaId the ID of the parking area to update + * @param parkingAreaUpdateRequest the request containing the new capacity + * @return the updated parking area + */ ParkingArea parkingAreaUpdateByCapacity( final String parkingAreaId, final ParkingAreaUpdateRequest parkingAreaUpdateRequest ); + } diff --git a/src/main/java/com/project/parkinglot/service/parking_area/impl/ParkingAreaCreateServiceImpl.java b/src/main/java/com/project/parkinglot/service/parking_area/impl/ParkingAreaCreateServiceImpl.java index e3617ed..19aedfe 100644 --- a/src/main/java/com/project/parkinglot/service/parking_area/impl/ParkingAreaCreateServiceImpl.java +++ b/src/main/java/com/project/parkinglot/service/parking_area/impl/ParkingAreaCreateServiceImpl.java @@ -16,6 +16,9 @@ import java.util.Objects; +/** + * Service implementation class named {@link ParkingAreaCreateServiceImpl} for creating parking areas. + */ @Service @RequiredArgsConstructor class ParkingAreaCreateServiceImpl implements ParkingAreaCreateService { @@ -29,6 +32,12 @@ class ParkingAreaCreateServiceImpl implements ParkingAreaCreateService { private final ParkingAreaEntityToParkingAreaMapper parkingAreaEntityToParkingAreaMapper = ParkingAreaEntityToParkingAreaMapper.initialize(); + /** + * Creates a new parking area. + * + * @param parkingAreaCreateRequest the request containing details for creating the parking area + * @return the created parking area + */ @Override public ParkingArea createParkingArea( final ParkingAreaCreateRequest parkingAreaCreateRequest @@ -54,6 +63,13 @@ public ParkingArea createParkingArea( .map(parkingAreaToBeCreate); } + /** + * Checks if a parking area with the given name and location already exists. + * + * @param name the name of the parking area to check + * @param location the location of the parking area to check + * @throws ParkingAreaAlreadyExistException if a parking area with the same name and location already exists + */ private void checkParkingAreaNameAndLocationUniqueness( final String name, final String location @@ -63,5 +79,6 @@ private void checkParkingAreaNameAndLocationUniqueness( throw new ParkingAreaAlreadyExistException(); } } + } diff --git a/src/main/java/com/project/parkinglot/service/parking_area/impl/ParkingAreaDeleteServiceImpl.java b/src/main/java/com/project/parkinglot/service/parking_area/impl/ParkingAreaDeleteServiceImpl.java index 23f57c3..8db3d17 100644 --- a/src/main/java/com/project/parkinglot/service/parking_area/impl/ParkingAreaDeleteServiceImpl.java +++ b/src/main/java/com/project/parkinglot/service/parking_area/impl/ParkingAreaDeleteServiceImpl.java @@ -7,6 +7,9 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +/** + * Service implementation class named {@link ParkingAreaDeleteServiceImpl} for deleting parking areas. + */ @Service @RequiredArgsConstructor class ParkingAreaDeleteServiceImpl implements ParkingAreaDeleteService { @@ -14,6 +17,11 @@ class ParkingAreaDeleteServiceImpl implements ParkingAreaDeleteService { private final ParkingAreaRepository parkingAreaRepository; + /** + * Deletes a parking area by its ID. + * + * @param parkingAreaId the ID of the parking area to delete + */ @Override public void deleteParkingAreaById( final String parkingAreaId diff --git a/src/main/java/com/project/parkinglot/service/parking_area/impl/ParkingAreaGetServiceImpl.java b/src/main/java/com/project/parkinglot/service/parking_area/impl/ParkingAreaGetServiceImpl.java index a4b271a..26f1723 100644 --- a/src/main/java/com/project/parkinglot/service/parking_area/impl/ParkingAreaGetServiceImpl.java +++ b/src/main/java/com/project/parkinglot/service/parking_area/impl/ParkingAreaGetServiceImpl.java @@ -15,6 +15,9 @@ import java.math.BigDecimal; import java.time.LocalDate; +/** + * Service implementation class named {@link ParkingAreaGetServiceImpl} for getting parking areas. + */ @Service @RequiredArgsConstructor class ParkingAreaGetServiceImpl implements ParkingAreaGetService { @@ -25,7 +28,12 @@ class ParkingAreaGetServiceImpl implements ParkingAreaGetService { ParkingAreaEntityToParkingAreaMapper.initialize(); - + /** + * Retrieves a parking area by its ID. + * + * @param parkingAreaId the ID of the parking area to retrieve + * @return the retrieved parking area + */ @Override public ParkingArea getParkingAreaById(final String parkingAreaId) { @@ -36,6 +44,12 @@ public ParkingArea getParkingAreaById(final String parkingAreaId) { } + /** + * Retrieves a parking area by its name. + * + * @param name the name of the parking area to retrieve + * @return the retrieved parking area + */ @Override public ParkingArea getParkingAreaByName(final String name) { @@ -46,6 +60,13 @@ public ParkingArea getParkingAreaByName(final String name) { } + /** + * Retrieves daily income for a parking area on a given date. + * + * @param date the date for which to retrieve income + * @param parkingAreaId the ID of the parking area + * @return the daily income of the parking area + */ @Override public ParkingAreaIncomeResponse getDailyIncome(final LocalDate date, final String parkingAreaId) { @@ -64,6 +85,12 @@ public ParkingAreaIncomeResponse getDailyIncome(final LocalDate date, final Stri .build(); } + /** + * Checks if the given date is after the current date. + * + * @param date the date to check + * @throws InvalidDateException if the given date is after the current date + */ private void isGivenDateAfterCurrentDate(final LocalDate date) { if (Boolean.TRUE.equals(date.isAfter(LocalDate.now()))) { throw new InvalidDateException(); diff --git a/src/main/java/com/project/parkinglot/service/parking_area/impl/ParkingAreaUpdateServiceImpl.java b/src/main/java/com/project/parkinglot/service/parking_area/impl/ParkingAreaUpdateServiceImpl.java index f9d0db7..b84f78a 100644 --- a/src/main/java/com/project/parkinglot/service/parking_area/impl/ParkingAreaUpdateServiceImpl.java +++ b/src/main/java/com/project/parkinglot/service/parking_area/impl/ParkingAreaUpdateServiceImpl.java @@ -10,7 +10,9 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; - +/** + * Service implementation class named {@link ParkingAreaUpdateServiceImpl} for updating parking areas. + */ @Service @RequiredArgsConstructor class ParkingAreaUpdateServiceImpl implements ParkingAreaUpdateService { @@ -20,6 +22,13 @@ class ParkingAreaUpdateServiceImpl implements ParkingAreaUpdateService { private final ParkingAreaEntityToParkingAreaMapper parkingAreaEntityToParkingArea = ParkingAreaEntityToParkingAreaMapper.initialize(); + /** + * Updates the capacity of a parking area. + * + * @param parkingAreaId the ID of the parking area to update + * @param parkingAreaUpdateRequest the request containing the new capacity + * @return the updated parking area + */ @Override public ParkingArea parkingAreaUpdateByCapacity( final String parkingAreaId, @@ -35,6 +44,7 @@ public ParkingArea parkingAreaUpdateByCapacity( parkingAreaRepository.save(parkingAreaEntityToBeUpdate); return parkingAreaEntityToParkingArea.map(parkingAreaEntityToBeUpdate); + } } diff --git a/src/main/java/com/project/parkinglot/service/price/PriceCreateService.java b/src/main/java/com/project/parkinglot/service/price/PriceCreateService.java index a56a3ff..0c164eb 100644 --- a/src/main/java/com/project/parkinglot/service/price/PriceCreateService.java +++ b/src/main/java/com/project/parkinglot/service/price/PriceCreateService.java @@ -4,9 +4,21 @@ import com.project.parkinglot.model.PriceList; import com.project.parkinglot.model.dto.request.price.PriceCreateRequest; +/** + * Service interface named {@link PriceCreateService} for creating a price. + */ public interface PriceCreateService { + + /** + * Creates a new price. + * + * @param priceList the price list to which the price belongs + * @param priceCreateRequest the request containing the price details + * @return the created price + */ Price createPrice( final PriceList priceList, final PriceCreateRequest priceCreateRequest ); + } diff --git a/src/main/java/com/project/parkinglot/service/price/impl/PriceCreateServiceImpl.java b/src/main/java/com/project/parkinglot/service/price/impl/PriceCreateServiceImpl.java index ca3ba51..8dcf48d 100644 --- a/src/main/java/com/project/parkinglot/service/price/impl/PriceCreateServiceImpl.java +++ b/src/main/java/com/project/parkinglot/service/price/impl/PriceCreateServiceImpl.java @@ -8,16 +8,27 @@ import com.project.parkinglot.model.mapper.price.PriceMapper; import com.project.parkinglot.model.mapper.priceList.PriceListMapper; import com.project.parkinglot.repository.PriceRepository; +import com.project.parkinglot.service.parking_area.ParkingAreaCreateService; import com.project.parkinglot.service.price.PriceCreateService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +/** + * Service implementation class named {@link PriceCreateServiceImpl} for creating price. + */ @Service @RequiredArgsConstructor public class PriceCreateServiceImpl implements PriceCreateService { private final PriceRepository priceRepository; + /** + * Creates a new price. + * + * @param priceList the price list to which the price belongs + * @param priceCreateRequest the request containing the price details + * @return the created price + */ @Override public Price createPrice( final PriceList priceList, @@ -35,4 +46,5 @@ public Price createPrice( return PriceMapper .toDomainModel(priceEntityToBeSave); } + } diff --git a/src/main/java/com/project/parkinglot/service/priceList/PriceListCreateService.java b/src/main/java/com/project/parkinglot/service/priceList/PriceListCreateService.java index 66b4164..444d1e8 100644 --- a/src/main/java/com/project/parkinglot/service/priceList/PriceListCreateService.java +++ b/src/main/java/com/project/parkinglot/service/priceList/PriceListCreateService.java @@ -3,8 +3,19 @@ import com.project.parkinglot.model.PriceList; import com.project.parkinglot.model.dto.request.priceList.PriceListCreateRequest; +/** + * Service interface named {@link PriceListCreateService} for creating a price list. + */ public interface PriceListCreateService { + + /** + * Creates a new price list. + * + * @param priceListCreateRequest the request containing the price list details + * @return the created price list + */ PriceList createPriceList( final PriceListCreateRequest priceListCreateRequest ); + } diff --git a/src/main/java/com/project/parkinglot/service/priceList/impl/PriceListCreateServiceImpl.java b/src/main/java/com/project/parkinglot/service/priceList/impl/PriceListCreateServiceImpl.java index 94b028b..72d28ba 100644 --- a/src/main/java/com/project/parkinglot/service/priceList/impl/PriceListCreateServiceImpl.java +++ b/src/main/java/com/project/parkinglot/service/priceList/impl/PriceListCreateServiceImpl.java @@ -8,6 +8,7 @@ import com.project.parkinglot.model.mapper.priceList.PriceListMapper; import com.project.parkinglot.repository.PriceListRepository; import com.project.parkinglot.service.price.PriceCreateService; +import com.project.parkinglot.service.price.impl.PriceCreateServiceImpl; import com.project.parkinglot.service.priceList.PriceListCreateService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -15,6 +16,9 @@ import java.util.List; import java.util.Objects; +/** + * Service implementation class named {@link PriceListCreateServiceImpl} for creating price list. + */ @Service @RequiredArgsConstructor public class PriceListCreateServiceImpl implements PriceListCreateService { @@ -22,6 +26,12 @@ public class PriceListCreateServiceImpl implements PriceListCreateService { private final PriceListRepository priceListRepository; private final PriceCreateService priceCreateService; + /** + * Creates a new price list. + * + * @param priceListCreateRequest the request containing the price list details + * @return the created price list + */ @Override public PriceList createPriceList( final PriceListCreateRequest priceListCreateRequest @@ -34,10 +44,8 @@ public PriceList createPriceList( final PriceList priceListDomainModel = PriceListMapper .toDomainModel(priceListEntityToBeSave); - if (Objects.isNull(priceListCreateRequest.getPrices())) - { + if (Objects.isNull(priceListCreateRequest.getPrices())) { return priceListDomainModel; - } final List createdPrices = priceListCreateRequest @@ -57,4 +65,5 @@ public PriceList createPriceList( return priceListDomainModel; } + } diff --git a/src/main/java/com/project/parkinglot/service/user/UserGetService.java b/src/main/java/com/project/parkinglot/service/user/UserGetService.java index a0b294e..8c0c99b 100644 --- a/src/main/java/com/project/parkinglot/service/user/UserGetService.java +++ b/src/main/java/com/project/parkinglot/service/user/UserGetService.java @@ -2,10 +2,25 @@ import com.project.parkinglot.model.User; +/** + * Service interface named {@link UserGetService} for retrieving user information. + */ public interface UserGetService { + /** + * Retrieves a user by user ID. + * + * @param userId the ID of the user to retrieve + * @return the user + */ User getUserById(String userId); + /** + * Retrieves an admin user by admin ID. + * + * @param adminId the ID of the admin user to retrieve + * @return the admin user + */ User getAdminById(final String adminId); } diff --git a/src/main/java/com/project/parkinglot/service/user/impl/UserGetServiceImpl.java b/src/main/java/com/project/parkinglot/service/user/impl/UserGetServiceImpl.java index 1f8b9f8..5b70d86 100644 --- a/src/main/java/com/project/parkinglot/service/user/impl/UserGetServiceImpl.java +++ b/src/main/java/com/project/parkinglot/service/user/impl/UserGetServiceImpl.java @@ -5,10 +5,14 @@ import com.project.parkinglot.model.mapper.user.UserEntityToUserMapper; import com.project.parkinglot.security.model.entity.UserEntity; import com.project.parkinglot.service.auth.UserService; +import com.project.parkinglot.service.priceList.impl.PriceListCreateServiceImpl; import com.project.parkinglot.service.user.UserGetService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +/** + * Service implementation class named {@link UserGetServiceImpl} for getting user. + */ @Service @RequiredArgsConstructor public class UserGetServiceImpl implements UserGetService { @@ -17,6 +21,13 @@ public class UserGetServiceImpl implements UserGetService { private final UserEntityToUserMapper userEntityToUserMapper = UserEntityToUserMapper.initialize(); + /** + * Retrieves a user by user ID. + * + * @param userId the ID of the user to retrieve + * @return the user + * @throws UserNotFoundException if the user with the given ID is not found + */ @Override public User getUserById(String userId) { @@ -26,6 +37,13 @@ public User getUserById(String userId) { return userEntityToUserMapper.map(userEntity); } + /** + * Retrieves an admin user by admin ID. + * + * @param adminId the ID of the admin user to retrieve + * @return the admin user + * @throws UserNotFoundException if the admin user with the given ID is not found + */ @Override public User getAdminById(final String adminId) { diff --git a/src/main/java/com/project/parkinglot/service/vehicle/VehicleService.java b/src/main/java/com/project/parkinglot/service/vehicle/VehicleService.java index 3f8679b..569fa8c 100644 --- a/src/main/java/com/project/parkinglot/service/vehicle/VehicleService.java +++ b/src/main/java/com/project/parkinglot/service/vehicle/VehicleService.java @@ -5,17 +5,46 @@ import com.project.parkinglot.model.dto.response.VehicleParkingDetailResponse; import com.project.parkinglot.model.entity.VehicleEntity; +/** + * Service interface named {@link VehicleService} for managing vehicles. + */ public interface VehicleService { + /** + * Assigns a vehicle to a user. + * + * @param id the ID of the user + * @param vehicleRequest the vehicle details + * @return the assigned vehicle + */ Vehicle assignVehicleToUser ( String id, VehicleRequest vehicleRequest ); + /** + * Assigns a vehicle to a user if not assigned already; otherwise, retrieves the assigned vehicle. + * + * @param userId the ID of the user + * @param vehicleRequest the vehicle details + * @return the assigned or retrieved vehicle + */ Vehicle assignOrGet(final String userId, final VehicleRequest vehicleRequest); + /** + * Retrieves a vehicle entity by its license plate. + * + * @param licensePlate the license plate of the vehicle + * @return the vehicle entity + */ VehicleEntity findByLicensePlate(final String licensePlate); + /** + * Retrieves parking details of a vehicle by its license plate. + * + * @param licensePlate the license plate of the vehicle + * @return the parking details of the vehicle + */ VehicleParkingDetailResponse getParkingDetails(final String licensePlate); } diff --git a/src/main/java/com/project/parkinglot/service/vehicle/impl/VehicleServiceImpl.java b/src/main/java/com/project/parkinglot/service/vehicle/impl/VehicleServiceImpl.java index 7c1d3c7..eaec87a 100644 --- a/src/main/java/com/project/parkinglot/service/vehicle/impl/VehicleServiceImpl.java +++ b/src/main/java/com/project/parkinglot/service/vehicle/impl/VehicleServiceImpl.java @@ -15,6 +15,7 @@ import com.project.parkinglot.repository.VehicleRepository; import com.project.parkinglot.security.model.entity.UserEntity; import com.project.parkinglot.service.auth.UserService; +import com.project.parkinglot.service.user.impl.UserGetServiceImpl; import com.project.parkinglot.service.vehicle.VehicleService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -24,6 +25,9 @@ import java.util.Optional; import java.util.stream.Collectors; +/** + * Service implementation class named {@link VehicleServiceImpl} for managing vehicle operations. + */ @Service @RequiredArgsConstructor public class VehicleServiceImpl implements VehicleService { @@ -44,6 +48,13 @@ public class VehicleServiceImpl implements VehicleService { private final VehicleEntityToVehicleMapper vehicleEntityToVehicleMapper = VehicleEntityToVehicleMapper.initialize(); + /** + * Assigns a vehicle to a user. + * + * @param id the ID of the user + * @param vehicleRequest the vehicle details + * @return the assigned vehicle + */ @Override @Transactional public Vehicle assignVehicleToUser(final String id, final VehicleRequest vehicleRequest) { @@ -59,16 +70,28 @@ public Vehicle assignVehicleToUser(final String id, final VehicleRequest vehicle } + /** + * Checks if a vehicle with the given license plate already exists. + * + * @param vehicle the vehicle to check + * @throws VehicleAlreadyExist if a vehicle with the same license plate already exists + */ private void existByLicensePlate (final Vehicle vehicle){ if (Boolean.TRUE.equals(vehicleRepository.existsByLicensePlate(vehicle.getLicensePlate()))){ - throw new VehicleAlreadyExist(); - } } + /** + * Assigns a user to a vehicle and saves the vehicle entity. + * + * @param userEntity the user entity to assign to the vehicle + * @param vehicle the vehicle to assign the user to + * @return the persisted vehicle entity with the assigned user + * @throws VehicleAlreadyExist if a vehicle with the same license plate already exists + */ private VehicleEntity assignUserToVehicle(final UserEntity userEntity, final Vehicle vehicle){ existByLicensePlate(vehicle); @@ -84,6 +107,13 @@ private VehicleEntity assignUserToVehicle(final UserEntity userEntity, final Veh } + /** + * Assigns a vehicle to a user if not assigned already; otherwise, retrieves the assigned vehicle. + * + * @param userId the ID of the user + * @param vehicleRequest the vehicle details + * @return the assigned or retrieved vehicle + */ @Override @Transactional public Vehicle assignOrGet(final String userId, final VehicleRequest vehicleRequest) { @@ -95,6 +125,12 @@ public Vehicle assignOrGet(final String userId, final VehicleRequest vehicleRequ return vehicleEntityToVehicleMapper.map(vehicleEntity); } + /** + * Retrieves a vehicle entity by its license plate. + * + * @param licensePlate the license plate of the vehicle + * @return the vehicle entity + */ @Override public VehicleEntity findByLicensePlate(final String licensePlate) { return vehicleRepository @@ -102,6 +138,12 @@ public VehicleEntity findByLicensePlate(final String licensePlate) { .orElseThrow(VehicleNotFoundException::new); } + /** + * Retrieves parking details of a vehicle by its license plate. + * + * @param licensePlate the license plate of the vehicle + * @return the parking details of the vehicle + */ @Override public VehicleParkingDetailResponse getParkingDetails(final String licensePlate) { diff --git a/src/main/java/com/project/parkinglot/utils/RandomUtil.java b/src/main/java/com/project/parkinglot/utils/RandomUtil.java index 53d4514..13062f4 100644 --- a/src/main/java/com/project/parkinglot/utils/RandomUtil.java +++ b/src/main/java/com/project/parkinglot/utils/RandomUtil.java @@ -6,23 +6,50 @@ import java.util.Random; import java.util.UUID; +/** + * Utility class named {@link RandomUtil} for generating random values. + */ @UtilityClass public class RandomUtil { private Random random = new Random(); + /** + * Generates a random UUID. + * + * @return a random UUID as a string + */ public static String generateUUID() { return UUID.randomUUID().toString(); } + /** + * Generates a random string. + * + * @return a random string + */ public static String generateRandomString() { return generateUUID().replace("-", ""); } + /** + * Generates a random integer within the specified range. + * + * @param min the minimum value (inclusive) + * @param max the maximum value (inclusive) + * @return a random integer within the specified range + */ public static Integer generateRandomInteger(int min, int max) { return random.nextInt(max - min + 1) + min; } + /** + * Generates a random BigDecimal within the specified range. + * + * @param min the minimum value (inclusive) + * @param max the maximum value (exclusive) + * @return a random BigDecimal within the specified range + */ public static BigDecimal generateRandomBigDecimal(double min, double max) { final int scale = 2; diff --git a/src/main/java/com/project/parkinglot/utils/price/FeeCalculationStrategy.java b/src/main/java/com/project/parkinglot/utils/price/FeeCalculationStrategy.java index cd63a32..095da08 100644 --- a/src/main/java/com/project/parkinglot/utils/price/FeeCalculationStrategy.java +++ b/src/main/java/com/project/parkinglot/utils/price/FeeCalculationStrategy.java @@ -2,8 +2,17 @@ import java.math.BigDecimal; +/** + * Defines a strategy named {@link FeeCalculationStrategy} to calculate the fee. + */ public interface FeeCalculationStrategy { + /** + * Calculates the price based on the given price. + * + * @param price the base price + * @return the calculated price + */ BigDecimal calculatePrice(BigDecimal price); } diff --git a/src/main/java/com/project/parkinglot/utils/price/FeeCalculationUtil.java b/src/main/java/com/project/parkinglot/utils/price/FeeCalculationUtil.java index c4fa571..69ebea8 100644 --- a/src/main/java/com/project/parkinglot/utils/price/FeeCalculationUtil.java +++ b/src/main/java/com/project/parkinglot/utils/price/FeeCalculationUtil.java @@ -11,6 +11,9 @@ import java.time.Duration; import java.util.Map; +/** + * Utility class named {@link FeeCalculationUtil} for calculating fees based on vehicle type. + */ @UtilityClass public class FeeCalculationUtil { @@ -20,7 +23,14 @@ VehicleType.SUV, new SuvFeeCalculatorStrategy(), VehicleType.MINIVAN, new MinivanFeeCalculatorStrategy() ); - + /** + * Finds the price for the time interval. + * + * @param parkingAreaPriceListEntity the price list entity for the parking area + * @param parkEntity the park entity + * @return the price for the time interval + * @throws PriceListNotFoundException if the price list is not found + */ public BigDecimal findPriceForTimeInterval( final PriceListEntity parkingAreaPriceListEntity, final ParkEntity parkEntity @@ -39,6 +49,13 @@ public BigDecimal findPriceForTimeInterval( } + /** + * Checks if the spent time is within the time interval defined by the price entity. + * + * @param priceEntity the price entity + * @param spentTime the spent time + * @return {@code true} if the spent time is within the time interval, otherwise {@code false} + */ private static boolean isWithinTimeInterval( final PriceEntity priceEntity, final long spentTime @@ -48,6 +65,12 @@ private static boolean isWithinTimeInterval( return spentTime >= startHour && spentTime <= endHour; } + /** + * Calculates the spent time based on the check-in and check-out time of the park entity. + * + * @param parkEntity the park entity + * @return the spent time in hours + */ private static long getSpentTime( final ParkEntity parkEntity ){ diff --git a/src/main/java/com/project/parkinglot/utils/price/MinivanFeeCalculatorStrategy.java b/src/main/java/com/project/parkinglot/utils/price/MinivanFeeCalculatorStrategy.java index e9406e9..e9bcaed 100644 --- a/src/main/java/com/project/parkinglot/utils/price/MinivanFeeCalculatorStrategy.java +++ b/src/main/java/com/project/parkinglot/utils/price/MinivanFeeCalculatorStrategy.java @@ -2,10 +2,19 @@ import java.math.BigDecimal; +/** + * Strategy implementation class named {@link MinivanFeeCalculatorStrategy} for calculating parking fees for Minivan vehicles. + */ public class MinivanFeeCalculatorStrategy implements FeeCalculationStrategy { private static final double MINIVAN_FEE_RATE = 0.15; + /** + * Calculates the total parking price for Minivan vehicles. + * + * @param price the base price + * @return the total price including the fee + */ @Override public BigDecimal calculatePrice(BigDecimal price) { diff --git a/src/main/java/com/project/parkinglot/utils/price/SedanFeeCalculatorStrategy.java b/src/main/java/com/project/parkinglot/utils/price/SedanFeeCalculatorStrategy.java index 9ac54ca..06c3115 100644 --- a/src/main/java/com/project/parkinglot/utils/price/SedanFeeCalculatorStrategy.java +++ b/src/main/java/com/project/parkinglot/utils/price/SedanFeeCalculatorStrategy.java @@ -2,10 +2,19 @@ import java.math.BigDecimal; +/** + * Strategy implementation class named {@link SedanFeeCalculatorStrategy} for calculating parking fees for Sedan vehicles. + */ public class SedanFeeCalculatorStrategy implements FeeCalculationStrategy { private static final double SEDAN_FEE_RATE = 0; + /** + * Calculates the total parking price for Sedan vehicles. + * + * @param price the base price + * @return the total price including the fee + */ @Override public BigDecimal calculatePrice(BigDecimal price) { diff --git a/src/main/java/com/project/parkinglot/utils/price/SuvFeeCalculatorStrategy.java b/src/main/java/com/project/parkinglot/utils/price/SuvFeeCalculatorStrategy.java index 963a8bb..1f6b37b 100644 --- a/src/main/java/com/project/parkinglot/utils/price/SuvFeeCalculatorStrategy.java +++ b/src/main/java/com/project/parkinglot/utils/price/SuvFeeCalculatorStrategy.java @@ -2,10 +2,19 @@ import java.math.BigDecimal; +/** + * Strategy implementation class named {@link SuvFeeCalculatorStrategy} for calculating parking fees for Suv vehicles. + */ public class SuvFeeCalculatorStrategy implements FeeCalculationStrategy { private static final double SUV_FEE_RATE = 0.10; + /** + * Calculates the total parking price for Suv vehicles. + * + * @param price the base price + * @return the total price including the fee + */ @Override public BigDecimal calculatePrice(BigDecimal price) {