From 7f87a9f2a901b4f20bc0da2febe28fa3204ada0a Mon Sep 17 00:00:00 2001 From: omar mohammed Date: Sat, 10 May 2025 23:03:00 +0300 Subject: [PATCH 1/6] add api description for courier controller --- .../controllers/CourierController.java | 45 +++++++++++++++---- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/podzilla/courier/controllers/CourierController.java b/src/main/java/com/podzilla/courier/controllers/CourierController.java index 7f22e02..66935ec 100644 --- a/src/main/java/com/podzilla/courier/controllers/CourierController.java +++ b/src/main/java/com/podzilla/courier/controllers/CourierController.java @@ -1,8 +1,11 @@ package com.podzilla.courier.controllers; import com.podzilla.courier.dtos.couriers.*; -import com.podzilla.courier.models.Courier; import com.podzilla.courier.services.CourierService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.parameters.RequestBody; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.ResponseEntity; @@ -21,32 +24,58 @@ public CourierController(CourierService courierService) { } @GetMapping + @Operation(summary = "Get all couriers", description = "Retrieves a list of all couriers.") + @ApiResponse(responseCode = "200", description = "Successfully retrieved list of couriers") public ResponseEntity> getAllCouriers() { logger.info("Received request to get all couriers"); return ResponseEntity.ok(courierService.getAllCouriers()); } @GetMapping("/{id}") - public ResponseEntity getCourierById(@PathVariable String id) { + @Operation(summary = "Get courier by ID", description = "Retrieves a specific courier by their unique ID.") + @ApiResponse(responseCode = "200", description = "Courier found and returned") + @ApiResponse(responseCode = "404", description = "Courier not found") + public ResponseEntity getCourierById( + @Parameter(description = "ID of the courier to retrieve") @PathVariable String id) { logger.info("Received request to get courier with id {}", id); - return courierService.getCourierById(id).map(ResponseEntity::ok).orElse(ResponseEntity.notFound().build()); + return courierService.getCourierById(id) + .map(ResponseEntity::ok) + .orElse(ResponseEntity.notFound().build()); } @PostMapping - public ResponseEntity createCourier(@RequestBody CreateCourierRequestDto courier) { + @Operation(summary = "Create a new courier", description = "Adds a new courier to the system.") + @ApiResponse(responseCode = "200", description = "Courier successfully created") + public ResponseEntity createCourier( + @RequestBody(description = "Details of the courier to create") + @org.springframework.web.bind.annotation.RequestBody CreateCourierRequestDto courier) { logger.info("Received request to add courier"); return ResponseEntity.ok(courierService.createCourier(courier)); } @PutMapping("/{id}") - public ResponseEntity updateCourier(@PathVariable String id, @RequestBody UpdateCourierRequestDto courier) { + @Operation(summary = "Update a courier", description = "Updates details of an existing courier.") + @ApiResponse(responseCode = "200", description = "Courier updated successfully") + @ApiResponse(responseCode = "404", description = "Courier not found") + public ResponseEntity updateCourier( + @Parameter(description = "ID of the courier to update") @PathVariable String id, + @RequestBody(description = "Updated courier details") + @org.springframework.web.bind.annotation.RequestBody UpdateCourierRequestDto courier) { logger.info("Received request to update courier with id {}", id); - return courierService.updateCourier(id, courier).map(ResponseEntity::ok).orElse(ResponseEntity.notFound().build()); + return courierService.updateCourier(id, courier) + .map(ResponseEntity::ok) + .orElse(ResponseEntity.notFound().build()); } @DeleteMapping("/{id}") - public ResponseEntity deleteCourier(@PathVariable String id) { + @Operation(summary = "Delete a courier", description = "Removes a courier from the system.") + @ApiResponse(responseCode = "200", description = "Courier deleted successfully") + @ApiResponse(responseCode = "404", description = "Courier not found") + public ResponseEntity deleteCourier( + @Parameter(description = "ID of the courier to delete") @PathVariable String id) { logger.info("Received request to delete courier with id {}", id); - return courierService.deleteCourier(id).map(ResponseEntity::ok).orElse(ResponseEntity.notFound().build()); + return courierService.deleteCourier(id) + .map(ResponseEntity::ok) + .orElse(ResponseEntity.notFound().build()); } } \ No newline at end of file From 8418b0656ecc7e016cbdb23dd6751337e9886fbe Mon Sep 17 00:00:00 2001 From: omar mohammed Date: Sat, 10 May 2025 23:05:27 +0300 Subject: [PATCH 2/6] add api description for delivery-task controller --- .../controllers/DeliveryTaskController.java | 107 ++++++++++++++---- 1 file changed, 87 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/podzilla/courier/controllers/DeliveryTaskController.java b/src/main/java/com/podzilla/courier/controllers/DeliveryTaskController.java index 176f4b3..5b11f47 100644 --- a/src/main/java/com/podzilla/courier/controllers/DeliveryTaskController.java +++ b/src/main/java/com/podzilla/courier/controllers/DeliveryTaskController.java @@ -1,6 +1,10 @@ package com.podzilla.courier.controllers; import com.podzilla.courier.dtos.delivery_tasks.*; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.parameters.RequestBody; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.util.Pair; @@ -24,25 +28,41 @@ public DeliveryTaskController(DeliveryTaskService deliveryTaskService) { } @PostMapping - public ResponseEntity createDeliveryTask(@RequestBody CreateDeliveryTaskRequestDto deliveryTaskRequestDto) { + @Operation(summary = "Create delivery task", description = "Creates a new delivery task") + @ApiResponse(responseCode = "200", description = "Delivery task created successfully") + public ResponseEntity createDeliveryTask( + @RequestBody(description = "Delivery task creation details") + @org.springframework.web.bind.annotation.RequestBody CreateDeliveryTaskRequestDto deliveryTaskRequestDto) { logger.info("Received request to create delivery task"); return ResponseEntity.ok(deliveryTaskService.createDeliveryTask(deliveryTaskRequestDto)); } @PatchMapping("/{id}") - public ResponseEntity> updateDeliveryTaskStatus(@PathVariable String id, @RequestBody UpdateDeliveryStatusRequestDto statusDto) { + @Operation(summary = "Update delivery task status", description = "Updates the status of a delivery task") + @ApiResponse(responseCode = "200", description = "Status updated successfully") + @ApiResponse(responseCode = "404", description = "Delivery task not found") + public ResponseEntity> updateDeliveryTaskStatus( + @Parameter(description = "ID of the delivery task") @PathVariable String id, + @RequestBody(description = "New status details") + @org.springframework.web.bind.annotation.RequestBody UpdateDeliveryStatusRequestDto statusDto) { logger.info("Received request to update delivery task with id {}", id); return ResponseEntity.ok(deliveryTaskService.updateDeliveryTaskStatus(id, statusDto.getStatus())); } @GetMapping + @Operation(summary = "Get all delivery tasks", description = "Retrieves all delivery tasks") + @ApiResponse(responseCode = "200", description = "Successfully retrieved all tasks") public ResponseEntity> getAllDeliveryTasks() { logger.info("Received request to get all delivery tasks"); return ResponseEntity.ok(deliveryTaskService.getAllDeliveryTasks()); } @GetMapping("/{id}") - public ResponseEntity getDeliveryTaskById(@PathVariable String id) { + @Operation(summary = "Get delivery task by ID", description = "Retrieves a specific delivery task") + @ApiResponse(responseCode = "200", description = "Delivery task found") + @ApiResponse(responseCode = "404", description = "Delivery task not found") + public ResponseEntity getDeliveryTaskById( + @Parameter(description = "ID of the delivery task") @PathVariable String id) { logger.info("Received request to get delivery task with id {}", id); return deliveryTaskService.getDeliveryTaskById(id) .map(ResponseEntity::ok) @@ -50,60 +70,107 @@ public ResponseEntity getDeliveryTaskById(@PathVariable } @GetMapping("/courier/{courierId}") - public ResponseEntity> getDeliveryTasksByCourierId(@PathVariable String courierId) { + @Operation(summary = "Get tasks by courier ID", description = "Retrieves delivery tasks for a specific courier") + @ApiResponse(responseCode = "200", description = "Tasks retrieved successfully") + public ResponseEntity> getDeliveryTasksByCourierId( + @Parameter(description = "ID of the courier") @PathVariable String courierId) { logger.info("Received request to get delivery task with courier id {}", courierId); return ResponseEntity.ok(deliveryTaskService.getDeliveryTasksByCourierId(courierId)); } @GetMapping("/status/{status}") - public ResponseEntity> getDeliveryTasksByStatus(@PathVariable DeliveryStatus status) { + @Operation(summary = "Get tasks by status", description = "Retrieves delivery tasks filtered by status") + @ApiResponse(responseCode = "200", description = "Tasks retrieved successfully") + public ResponseEntity> getDeliveryTasksByStatus( + @Parameter(description = "Delivery status filter") @PathVariable DeliveryStatus status) { logger.info("Received request to get delivery task with status {}", status); return ResponseEntity.ok(deliveryTaskService.getDeliveryTasksByStatus(status)); } @GetMapping("/order/{orderId}") - public ResponseEntity> getDeliveryTasksByOrderId(@PathVariable String orderId) { + @Operation(summary = "Get tasks by order ID", description = "Retrieves delivery tasks for a specific order") + @ApiResponse(responseCode = "200", description = "Tasks retrieved successfully") + public ResponseEntity> getDeliveryTasksByOrderId( + @Parameter(description = "ID of the order") @PathVariable String orderId) { logger.info("Received request to get delivery task with order id {}", orderId); return ResponseEntity.ok(deliveryTaskService.getDeliveryTasksByOrderId(orderId)); } @GetMapping("/{id}/location") - public ResponseEntity> getDeliveryTaskLocation(@PathVariable String id) { + @Operation(summary = "Get task location", description = "Retrieves coordinates of a delivery task") + @ApiResponse(responseCode = "200", description = "Location retrieved successfully") + @ApiResponse(responseCode = "404", description = "Task not found") + public ResponseEntity> getDeliveryTaskLocation( + @Parameter(description = "ID of the delivery task") @PathVariable String id) { logger.info("Received request to get the location of delivery task with id {}", id); return ResponseEntity.ok(deliveryTaskService.getDeliveryTaskLocation(id)); } @PatchMapping("/{id}/location") - public ResponseEntity updateDeliveryTaskLocation(@PathVariable String id, @RequestBody LocationUpdateDto locationUpdateDto) { - logger.info("Received request to update the location if delivery task with id {}", id); - return ResponseEntity.ok(deliveryTaskService.updateDeliveryTaskLocation(id, locationUpdateDto.getLatitude(), locationUpdateDto.getLongitude())); + @Operation(summary = "Update task location", description = "Updates coordinates of a delivery task") + @ApiResponse(responseCode = "200", description = "Location updated successfully") + public ResponseEntity updateDeliveryTaskLocation( + @Parameter(description = "ID of the delivery task") @PathVariable String id, + @RequestBody(description = "New coordinates data") + @org.springframework.web.bind.annotation.RequestBody LocationUpdateDto locationUpdateDto) { + logger.info("Received request to update the location of delivery task with id {}", id); + return ResponseEntity.ok(deliveryTaskService.updateDeliveryTaskLocation( + id, locationUpdateDto.getLatitude(), locationUpdateDto.getLongitude())); } @PatchMapping("/{id}/cancel") - public ResponseEntity cancelDeliveryTask(@PathVariable String id, @RequestBody CancelDeliveryTaskRequestDto cancelTaskDto) { + @Operation(summary = "Cancel delivery task", description = "Cancels a delivery task with a reason") + @ApiResponse(responseCode = "200", description = "Task cancelled successfully") + public ResponseEntity cancelDeliveryTask( + @Parameter(description = "ID of the delivery task") @PathVariable String id, + @RequestBody(description = "Cancellation details") + @org.springframework.web.bind.annotation.RequestBody CancelDeliveryTaskRequestDto cancelTaskDto) { logger.info("Received request to cancel delivery task with id {}", id); return ResponseEntity.ok(deliveryTaskService.cancelDeliveryTask(id, cancelTaskDto.cancellationReason())); } @PatchMapping("/{id}/rate") - public ResponseEntity submitCourierRating(@PathVariable String id, @RequestBody SubmitCourierRatingRequestDto ratingDto) { + @Operation(summary = "Submit courier rating", description = "Submits a rating for the courier's performance") + @ApiResponse(responseCode = "200", description = "Rating submitted successfully") + public ResponseEntity submitCourierRating( + @Parameter(description = "ID of the delivery task") @PathVariable String id, + @RequestBody(description = "Rating details") + @org.springframework.web.bind.annotation.RequestBody SubmitCourierRatingRequestDto ratingDto) { return ResponseEntity.ok(deliveryTaskService.submitCourierRating(id, ratingDto.getRating())); } @DeleteMapping("/{id}") - public ResponseEntity deleteDeliveryTask(@PathVariable String id) { + @Operation(summary = "Delete delivery task", description = "Permanently removes a delivery task") + @ApiResponse(responseCode = "200", description = "Task deleted successfully") + public ResponseEntity deleteDeliveryTask( + @Parameter(description = "ID of the delivery task") @PathVariable String id) { logger.info("Received request to delete delivery task with id {}", id); return ResponseEntity.ok(deliveryTaskService.deleteDeliveryTask(id)); } - + @PutMapping("/{id}/otp") - public ResponseEntity updateOtp(@PathVariable String id, @RequestBody String otp) { - return deliveryTaskService.updateOtp(id, otp).map(ResponseEntity::ok).orElse(ResponseEntity.notFound().build()); + @Operation(summary = "Update OTP", description = "Updates the One-Time Password for a delivery task") + @ApiResponse(responseCode = "200", description = "OTP updated successfully") + @ApiResponse(responseCode = "404", description = "Task not found") + public ResponseEntity updateOtp( + @Parameter(description = "ID of the delivery task") @PathVariable String id, + @RequestBody(description = "New OTP value") + @org.springframework.web.bind.annotation.RequestBody String otp) { + return deliveryTaskService.updateOtp(id, otp) + .map(ResponseEntity::ok) + .orElse(ResponseEntity.notFound().build()); } @PutMapping("/{id}/otp-confirmation") - public ResponseEntity confirmOTP(@PathVariable String id, @RequestBody String otp) { - return deliveryTaskService.confirmOTP(id, otp).map(ResponseEntity::ok).orElse(ResponseEntity.notFound().build()); + @Operation(summary = "Confirm OTP", description = "Validates the One-Time Password for a delivery task") + @ApiResponse(responseCode = "200", description = "OTP confirmed successfully") + @ApiResponse(responseCode = "404", description = "Invalid OTP or task not found") + public ResponseEntity confirmOTP( + @Parameter(description = "ID of the delivery task") @PathVariable String id, + @RequestBody(description = "OTP to validate") + @org.springframework.web.bind.annotation.RequestBody String otp) { + return deliveryTaskService.confirmOTP(id, otp) + .map(ResponseEntity::ok) + .orElse(ResponseEntity.notFound().build()); } - -} +} \ No newline at end of file From 9836f49734a734767b561375362645c51dd459d3 Mon Sep 17 00:00:00 2001 From: omar mohammed Date: Sat, 10 May 2025 23:12:20 +0300 Subject: [PATCH 3/6] ensure line length doesn't exceed 80 characters --- .../controllers/DeliveryTaskController.java | 213 ++++++++++++------ 1 file changed, 143 insertions(+), 70 deletions(-) diff --git a/src/main/java/com/podzilla/courier/controllers/DeliveryTaskController.java b/src/main/java/com/podzilla/courier/controllers/DeliveryTaskController.java index 5b11f47..621cc9e 100644 --- a/src/main/java/com/podzilla/courier/controllers/DeliveryTaskController.java +++ b/src/main/java/com/podzilla/courier/controllers/DeliveryTaskController.java @@ -21,48 +21,67 @@ public class DeliveryTaskController { private final DeliveryTaskService deliveryTaskService; - private static final Logger logger = LoggerFactory.getLogger(DeliveryTaskController.class); + private static final Logger logger = + LoggerFactory.getLogger(DeliveryTaskController.class); public DeliveryTaskController(DeliveryTaskService deliveryTaskService) { this.deliveryTaskService = deliveryTaskService; } @PostMapping - @Operation(summary = "Create delivery task", description = "Creates a new delivery task") - @ApiResponse(responseCode = "200", description = "Delivery task created successfully") + @Operation(summary = "Create delivery task", + description = "Creates a new delivery task") + @ApiResponse(responseCode = "200", + description = "Delivery task created successfully") public ResponseEntity createDeliveryTask( @RequestBody(description = "Delivery task creation details") - @org.springframework.web.bind.annotation.RequestBody CreateDeliveryTaskRequestDto deliveryTaskRequestDto) { + @org.springframework.web.bind.annotation.RequestBody + CreateDeliveryTaskRequestDto deliveryTaskRequestDto) { logger.info("Received request to create delivery task"); - return ResponseEntity.ok(deliveryTaskService.createDeliveryTask(deliveryTaskRequestDto)); + return ResponseEntity.ok( + deliveryTaskService.createDeliveryTask(deliveryTaskRequestDto)); } @PatchMapping("/{id}") - @Operation(summary = "Update delivery task status", description = "Updates the status of a delivery task") - @ApiResponse(responseCode = "200", description = "Status updated successfully") - @ApiResponse(responseCode = "404", description = "Delivery task not found") - public ResponseEntity> updateDeliveryTaskStatus( - @Parameter(description = "ID of the delivery task") @PathVariable String id, + @Operation(summary = "Update delivery task status", + description = "Updates the status of a delivery task") + @ApiResponse(responseCode = "200", + description = "Status updated successfully") + @ApiResponse(responseCode = "404", + description = "Delivery task not found") + public ResponseEntity> + updateDeliveryTaskStatus( + @Parameter(description = "ID of the delivery task") + @PathVariable String id, @RequestBody(description = "New status details") - @org.springframework.web.bind.annotation.RequestBody UpdateDeliveryStatusRequestDto statusDto) { + @org.springframework.web.bind.annotation.RequestBody + UpdateDeliveryStatusRequestDto statusDto) { logger.info("Received request to update delivery task with id {}", id); - return ResponseEntity.ok(deliveryTaskService.updateDeliveryTaskStatus(id, statusDto.getStatus())); + return ResponseEntity.ok( + deliveryTaskService.updateDeliveryTaskStatus( + id, statusDto.getStatus())); } @GetMapping - @Operation(summary = "Get all delivery tasks", description = "Retrieves all delivery tasks") - @ApiResponse(responseCode = "200", description = "Successfully retrieved all tasks") + @Operation(summary = "Get all delivery tasks", + description = "Retrieves all delivery tasks") + @ApiResponse(responseCode = "200", + description = "Successfully retrieved all tasks") public ResponseEntity> getAllDeliveryTasks() { logger.info("Received request to get all delivery tasks"); return ResponseEntity.ok(deliveryTaskService.getAllDeliveryTasks()); } @GetMapping("/{id}") - @Operation(summary = "Get delivery task by ID", description = "Retrieves a specific delivery task") - @ApiResponse(responseCode = "200", description = "Delivery task found") - @ApiResponse(responseCode = "404", description = "Delivery task not found") + @Operation(summary = "Get delivery task by ID", + description = "Retrieves a specific delivery task") + @ApiResponse(responseCode = "200", + description = "Delivery task found") + @ApiResponse(responseCode = "404", + description = "Delivery task not found") public ResponseEntity getDeliveryTaskById( - @Parameter(description = "ID of the delivery task") @PathVariable String id) { + @Parameter(description = "ID of the delivery task") + @PathVariable String id) { logger.info("Received request to get delivery task with id {}", id); return deliveryTaskService.getDeliveryTaskById(id) .map(ResponseEntity::ok) @@ -70,90 +89,140 @@ public ResponseEntity getDeliveryTaskById( } @GetMapping("/courier/{courierId}") - @Operation(summary = "Get tasks by courier ID", description = "Retrieves delivery tasks for a specific courier") - @ApiResponse(responseCode = "200", description = "Tasks retrieved successfully") - public ResponseEntity> getDeliveryTasksByCourierId( - @Parameter(description = "ID of the courier") @PathVariable String courierId) { - logger.info("Received request to get delivery task with courier id {}", courierId); - return ResponseEntity.ok(deliveryTaskService.getDeliveryTasksByCourierId(courierId)); + @Operation(summary = "Get tasks by courier ID", + description = "Retrieves delivery tasks for a specific courier") + @ApiResponse(responseCode = "200", + description = "Tasks retrieved successfully") + public ResponseEntity> + getDeliveryTasksByCourierId( + @Parameter(description = "ID of the courier") + @PathVariable String courierId) { + logger.info("Received request to get delivery task with courier id {}", + courierId); + return ResponseEntity.ok( + deliveryTaskService.getDeliveryTasksByCourierId(courierId)); } @GetMapping("/status/{status}") - @Operation(summary = "Get tasks by status", description = "Retrieves delivery tasks filtered by status") - @ApiResponse(responseCode = "200", description = "Tasks retrieved successfully") - public ResponseEntity> getDeliveryTasksByStatus( - @Parameter(description = "Delivery status filter") @PathVariable DeliveryStatus status) { - logger.info("Received request to get delivery task with status {}", status); - return ResponseEntity.ok(deliveryTaskService.getDeliveryTasksByStatus(status)); + @Operation(summary = "Get tasks by status", + description = "Retrieves delivery tasks filtered by status") + @ApiResponse(responseCode = "200", + description = "Tasks retrieved successfully") + public ResponseEntity> + getDeliveryTasksByStatus( + @Parameter(description = "Delivery status filter") + @PathVariable DeliveryStatus status) { + logger.info("Received request to get delivery task with status {}", + status); + return ResponseEntity.ok( + deliveryTaskService.getDeliveryTasksByStatus(status)); } @GetMapping("/order/{orderId}") - @Operation(summary = "Get tasks by order ID", description = "Retrieves delivery tasks for a specific order") - @ApiResponse(responseCode = "200", description = "Tasks retrieved successfully") - public ResponseEntity> getDeliveryTasksByOrderId( - @Parameter(description = "ID of the order") @PathVariable String orderId) { - logger.info("Received request to get delivery task with order id {}", orderId); - return ResponseEntity.ok(deliveryTaskService.getDeliveryTasksByOrderId(orderId)); + @Operation(summary = "Get tasks by order ID", + description = "Retrieves delivery tasks for a specific order") + @ApiResponse(responseCode = "200", + description = "Tasks retrieved successfully") + public ResponseEntity> + getDeliveryTasksByOrderId( + @Parameter(description = "ID of the order") + @PathVariable String orderId) { + logger.info("Received request to get delivery task with order id {}", + orderId); + return ResponseEntity.ok( + deliveryTaskService.getDeliveryTasksByOrderId(orderId)); } @GetMapping("/{id}/location") - @Operation(summary = "Get task location", description = "Retrieves coordinates of a delivery task") - @ApiResponse(responseCode = "200", description = "Location retrieved successfully") - @ApiResponse(responseCode = "404", description = "Task not found") + @Operation(summary = "Get task location", + description = "Retrieves coordinates of a delivery task") + @ApiResponse(responseCode = "200", + description = "Location retrieved successfully") + @ApiResponse(responseCode = "404", + description = "Task not found") public ResponseEntity> getDeliveryTaskLocation( - @Parameter(description = "ID of the delivery task") @PathVariable String id) { - logger.info("Received request to get the location of delivery task with id {}", id); - return ResponseEntity.ok(deliveryTaskService.getDeliveryTaskLocation(id)); + @Parameter(description = "ID of the delivery task") + @PathVariable String id) { + logger.info("Received request to get the location of delivery task " + + "with id {}", id); + return ResponseEntity.ok( + deliveryTaskService.getDeliveryTaskLocation(id)); } @PatchMapping("/{id}/location") - @Operation(summary = "Update task location", description = "Updates coordinates of a delivery task") - @ApiResponse(responseCode = "200", description = "Location updated successfully") + @Operation(summary = "Update task location", + description = "Updates coordinates of a delivery task") + @ApiResponse(responseCode = "200", + description = "Location updated successfully") public ResponseEntity updateDeliveryTaskLocation( - @Parameter(description = "ID of the delivery task") @PathVariable String id, + @Parameter(description = "ID of the delivery task") + @PathVariable String id, @RequestBody(description = "New coordinates data") - @org.springframework.web.bind.annotation.RequestBody LocationUpdateDto locationUpdateDto) { - logger.info("Received request to update the location of delivery task with id {}", id); - return ResponseEntity.ok(deliveryTaskService.updateDeliveryTaskLocation( - id, locationUpdateDto.getLatitude(), locationUpdateDto.getLongitude())); + @org.springframework.web.bind.annotation.RequestBody + LocationUpdateDto locationUpdateDto) { + logger.info("Received request to update the location of delivery " + + "task with id {}", id); + return ResponseEntity.ok( + deliveryTaskService.updateDeliveryTaskLocation( + id, + locationUpdateDto.getLatitude(), + locationUpdateDto.getLongitude())); } @PatchMapping("/{id}/cancel") - @Operation(summary = "Cancel delivery task", description = "Cancels a delivery task with a reason") - @ApiResponse(responseCode = "200", description = "Task cancelled successfully") + @Operation(summary = "Cancel delivery task", + description = "Cancels a delivery task with a reason") + @ApiResponse(responseCode = "200", + description = "Task cancelled successfully") public ResponseEntity cancelDeliveryTask( - @Parameter(description = "ID of the delivery task") @PathVariable String id, + @Parameter(description = "ID of the delivery task") + @PathVariable String id, @RequestBody(description = "Cancellation details") - @org.springframework.web.bind.annotation.RequestBody CancelDeliveryTaskRequestDto cancelTaskDto) { + @org.springframework.web.bind.annotation.RequestBody + CancelDeliveryTaskRequestDto cancelTaskDto) { logger.info("Received request to cancel delivery task with id {}", id); - return ResponseEntity.ok(deliveryTaskService.cancelDeliveryTask(id, cancelTaskDto.cancellationReason())); + return ResponseEntity.ok( + deliveryTaskService.cancelDeliveryTask( + id, cancelTaskDto.cancellationReason())); } @PatchMapping("/{id}/rate") - @Operation(summary = "Submit courier rating", description = "Submits a rating for the courier's performance") - @ApiResponse(responseCode = "200", description = "Rating submitted successfully") + @Operation(summary = "Submit courier rating", + description = "Submits a rating for the courier's performance") + @ApiResponse(responseCode = "200", + description = "Rating submitted successfully") public ResponseEntity submitCourierRating( - @Parameter(description = "ID of the delivery task") @PathVariable String id, + @Parameter(description = "ID of the delivery task") + @PathVariable String id, @RequestBody(description = "Rating details") - @org.springframework.web.bind.annotation.RequestBody SubmitCourierRatingRequestDto ratingDto) { - return ResponseEntity.ok(deliveryTaskService.submitCourierRating(id, ratingDto.getRating())); + @org.springframework.web.bind.annotation.RequestBody + SubmitCourierRatingRequestDto ratingDto) { + return ResponseEntity.ok( + deliveryTaskService.submitCourierRating(id, ratingDto.getRating())); } @DeleteMapping("/{id}") - @Operation(summary = "Delete delivery task", description = "Permanently removes a delivery task") - @ApiResponse(responseCode = "200", description = "Task deleted successfully") + @Operation(summary = "Delete delivery task", + description = "Permanently removes a delivery task") + @ApiResponse(responseCode = "200", + description = "Task deleted successfully") public ResponseEntity deleteDeliveryTask( - @Parameter(description = "ID of the delivery task") @PathVariable String id) { + @Parameter(description = "ID of the delivery task") + @PathVariable String id) { logger.info("Received request to delete delivery task with id {}", id); return ResponseEntity.ok(deliveryTaskService.deleteDeliveryTask(id)); } @PutMapping("/{id}/otp") - @Operation(summary = "Update OTP", description = "Updates the One-Time Password for a delivery task") - @ApiResponse(responseCode = "200", description = "OTP updated successfully") - @ApiResponse(responseCode = "404", description = "Task not found") + @Operation(summary = "Update OTP", + description = "Updates the One-Time Password for a delivery task") + @ApiResponse(responseCode = "200", + description = "OTP updated successfully") + @ApiResponse(responseCode = "404", + description = "Task not found") public ResponseEntity updateOtp( - @Parameter(description = "ID of the delivery task") @PathVariable String id, + @Parameter(description = "ID of the delivery task") + @PathVariable String id, @RequestBody(description = "New OTP value") @org.springframework.web.bind.annotation.RequestBody String otp) { return deliveryTaskService.updateOtp(id, otp) @@ -162,11 +231,15 @@ public ResponseEntity updateOtp( } @PutMapping("/{id}/otp-confirmation") - @Operation(summary = "Confirm OTP", description = "Validates the One-Time Password for a delivery task") - @ApiResponse(responseCode = "200", description = "OTP confirmed successfully") - @ApiResponse(responseCode = "404", description = "Invalid OTP or task not found") + @Operation(summary = "Confirm OTP", + description = "Validates the One-Time Password for a delivery task") + @ApiResponse(responseCode = "200", + description = "OTP confirmed successfully") + @ApiResponse(responseCode = "404", + description = "Invalid OTP or task not found") public ResponseEntity confirmOTP( - @Parameter(description = "ID of the delivery task") @PathVariable String id, + @Parameter(description = "ID of the delivery task") + @PathVariable String id, @RequestBody(description = "OTP to validate") @org.springframework.web.bind.annotation.RequestBody String otp) { return deliveryTaskService.confirmOTP(id, otp) From 8b134132ad73da9825a0a6d5903e1f5ed8b34fe7 Mon Sep 17 00:00:00 2001 From: omar mohammed Date: Sat, 10 May 2025 23:18:05 +0300 Subject: [PATCH 4/6] ensure line length doesn't exceed 80 characters in courier controller --- .../controllers/CourierController.java | 57 ++++++++++++------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/podzilla/courier/controllers/CourierController.java b/src/main/java/com/podzilla/courier/controllers/CourierController.java index 66935ec..2ea78e8 100644 --- a/src/main/java/com/podzilla/courier/controllers/CourierController.java +++ b/src/main/java/com/podzilla/courier/controllers/CourierController.java @@ -17,26 +17,33 @@ @RequestMapping("/couriers") public class CourierController { private final CourierService courierService; - private static final Logger logger = LoggerFactory.getLogger(CourierController.class); + private static final Logger logger = + LoggerFactory.getLogger(CourierController.class); public CourierController(CourierService courierService) { this.courierService = courierService; } @GetMapping - @Operation(summary = "Get all couriers", description = "Retrieves a list of all couriers.") - @ApiResponse(responseCode = "200", description = "Successfully retrieved list of couriers") + @Operation(summary = "Get all couriers", + description = "Retrieves a list of all couriers.") + @ApiResponse(responseCode = "200", + description = "Successfully retrieved list of couriers") public ResponseEntity> getAllCouriers() { logger.info("Received request to get all couriers"); return ResponseEntity.ok(courierService.getAllCouriers()); } @GetMapping("/{id}") - @Operation(summary = "Get courier by ID", description = "Retrieves a specific courier by their unique ID.") - @ApiResponse(responseCode = "200", description = "Courier found and returned") - @ApiResponse(responseCode = "404", description = "Courier not found") + @Operation(summary = "Get courier by ID", + description = "Retrieves a specific courier by their unique ID.") + @ApiResponse(responseCode = "200", + description = "Courier found and returned") + @ApiResponse(responseCode = "404", + description = "Courier not found") public ResponseEntity getCourierById( - @Parameter(description = "ID of the courier to retrieve") @PathVariable String id) { + @Parameter(description = "ID of the courier to retrieve") + @PathVariable String id) { logger.info("Received request to get courier with id {}", id); return courierService.getCourierById(id) .map(ResponseEntity::ok) @@ -44,23 +51,31 @@ public ResponseEntity getCourierById( } @PostMapping - @Operation(summary = "Create a new courier", description = "Adds a new courier to the system.") - @ApiResponse(responseCode = "200", description = "Courier successfully created") + @Operation(summary = "Create a new courier", + description = "Adds a new courier to the system.") + @ApiResponse(responseCode = "200", + description = "Courier successfully created") public ResponseEntity createCourier( @RequestBody(description = "Details of the courier to create") - @org.springframework.web.bind.annotation.RequestBody CreateCourierRequestDto courier) { + @org.springframework.web.bind.annotation.RequestBody + CreateCourierRequestDto courier) { logger.info("Received request to add courier"); return ResponseEntity.ok(courierService.createCourier(courier)); } @PutMapping("/{id}") - @Operation(summary = "Update a courier", description = "Updates details of an existing courier.") - @ApiResponse(responseCode = "200", description = "Courier updated successfully") - @ApiResponse(responseCode = "404", description = "Courier not found") + @Operation(summary = "Update a courier", + description = "Updates details of an existing courier.") + @ApiResponse(responseCode = "200", + description = "Courier updated successfully") + @ApiResponse(responseCode = "404", + description = "Courier not found") public ResponseEntity updateCourier( - @Parameter(description = "ID of the courier to update") @PathVariable String id, + @Parameter(description = "ID of the courier to update") + @PathVariable String id, @RequestBody(description = "Updated courier details") - @org.springframework.web.bind.annotation.RequestBody UpdateCourierRequestDto courier) { + @org.springframework.web.bind.annotation.RequestBody + UpdateCourierRequestDto courier) { logger.info("Received request to update courier with id {}", id); return courierService.updateCourier(id, courier) .map(ResponseEntity::ok) @@ -68,11 +83,15 @@ public ResponseEntity updateCourier( } @DeleteMapping("/{id}") - @Operation(summary = "Delete a courier", description = "Removes a courier from the system.") - @ApiResponse(responseCode = "200", description = "Courier deleted successfully") - @ApiResponse(responseCode = "404", description = "Courier not found") + @Operation(summary = "Delete a courier", + description = "Removes a courier from the system.") + @ApiResponse(responseCode = "200", + description = "Courier deleted successfully") + @ApiResponse(responseCode = "404", + description = "Courier not found") public ResponseEntity deleteCourier( - @Parameter(description = "ID of the courier to delete") @PathVariable String id) { + @Parameter(description = "ID of the courier to delete") + @PathVariable String id) { logger.info("Received request to delete courier with id {}", id); return courierService.deleteCourier(id) .map(ResponseEntity::ok) From 6817a0a19dd0fef9cda2b51163fae3e5ef5f87d0 Mon Sep 17 00:00:00 2001 From: omar mohammed Date: Sun, 11 May 2025 11:58:30 +0300 Subject: [PATCH 5/6] remove last 2 commits --- .../controllers/CourierController.java | 57 +++-- .../controllers/DeliveryTaskController.java | 213 ++++++++++++------ 2 files changed, 181 insertions(+), 89 deletions(-) diff --git a/src/main/java/com/podzilla/courier/controllers/CourierController.java b/src/main/java/com/podzilla/courier/controllers/CourierController.java index 66935ec..2ea78e8 100644 --- a/src/main/java/com/podzilla/courier/controllers/CourierController.java +++ b/src/main/java/com/podzilla/courier/controllers/CourierController.java @@ -17,26 +17,33 @@ @RequestMapping("/couriers") public class CourierController { private final CourierService courierService; - private static final Logger logger = LoggerFactory.getLogger(CourierController.class); + private static final Logger logger = + LoggerFactory.getLogger(CourierController.class); public CourierController(CourierService courierService) { this.courierService = courierService; } @GetMapping - @Operation(summary = "Get all couriers", description = "Retrieves a list of all couriers.") - @ApiResponse(responseCode = "200", description = "Successfully retrieved list of couriers") + @Operation(summary = "Get all couriers", + description = "Retrieves a list of all couriers.") + @ApiResponse(responseCode = "200", + description = "Successfully retrieved list of couriers") public ResponseEntity> getAllCouriers() { logger.info("Received request to get all couriers"); return ResponseEntity.ok(courierService.getAllCouriers()); } @GetMapping("/{id}") - @Operation(summary = "Get courier by ID", description = "Retrieves a specific courier by their unique ID.") - @ApiResponse(responseCode = "200", description = "Courier found and returned") - @ApiResponse(responseCode = "404", description = "Courier not found") + @Operation(summary = "Get courier by ID", + description = "Retrieves a specific courier by their unique ID.") + @ApiResponse(responseCode = "200", + description = "Courier found and returned") + @ApiResponse(responseCode = "404", + description = "Courier not found") public ResponseEntity getCourierById( - @Parameter(description = "ID of the courier to retrieve") @PathVariable String id) { + @Parameter(description = "ID of the courier to retrieve") + @PathVariable String id) { logger.info("Received request to get courier with id {}", id); return courierService.getCourierById(id) .map(ResponseEntity::ok) @@ -44,23 +51,31 @@ public ResponseEntity getCourierById( } @PostMapping - @Operation(summary = "Create a new courier", description = "Adds a new courier to the system.") - @ApiResponse(responseCode = "200", description = "Courier successfully created") + @Operation(summary = "Create a new courier", + description = "Adds a new courier to the system.") + @ApiResponse(responseCode = "200", + description = "Courier successfully created") public ResponseEntity createCourier( @RequestBody(description = "Details of the courier to create") - @org.springframework.web.bind.annotation.RequestBody CreateCourierRequestDto courier) { + @org.springframework.web.bind.annotation.RequestBody + CreateCourierRequestDto courier) { logger.info("Received request to add courier"); return ResponseEntity.ok(courierService.createCourier(courier)); } @PutMapping("/{id}") - @Operation(summary = "Update a courier", description = "Updates details of an existing courier.") - @ApiResponse(responseCode = "200", description = "Courier updated successfully") - @ApiResponse(responseCode = "404", description = "Courier not found") + @Operation(summary = "Update a courier", + description = "Updates details of an existing courier.") + @ApiResponse(responseCode = "200", + description = "Courier updated successfully") + @ApiResponse(responseCode = "404", + description = "Courier not found") public ResponseEntity updateCourier( - @Parameter(description = "ID of the courier to update") @PathVariable String id, + @Parameter(description = "ID of the courier to update") + @PathVariable String id, @RequestBody(description = "Updated courier details") - @org.springframework.web.bind.annotation.RequestBody UpdateCourierRequestDto courier) { + @org.springframework.web.bind.annotation.RequestBody + UpdateCourierRequestDto courier) { logger.info("Received request to update courier with id {}", id); return courierService.updateCourier(id, courier) .map(ResponseEntity::ok) @@ -68,11 +83,15 @@ public ResponseEntity updateCourier( } @DeleteMapping("/{id}") - @Operation(summary = "Delete a courier", description = "Removes a courier from the system.") - @ApiResponse(responseCode = "200", description = "Courier deleted successfully") - @ApiResponse(responseCode = "404", description = "Courier not found") + @Operation(summary = "Delete a courier", + description = "Removes a courier from the system.") + @ApiResponse(responseCode = "200", + description = "Courier deleted successfully") + @ApiResponse(responseCode = "404", + description = "Courier not found") public ResponseEntity deleteCourier( - @Parameter(description = "ID of the courier to delete") @PathVariable String id) { + @Parameter(description = "ID of the courier to delete") + @PathVariable String id) { logger.info("Received request to delete courier with id {}", id); return courierService.deleteCourier(id) .map(ResponseEntity::ok) diff --git a/src/main/java/com/podzilla/courier/controllers/DeliveryTaskController.java b/src/main/java/com/podzilla/courier/controllers/DeliveryTaskController.java index 5b11f47..621cc9e 100644 --- a/src/main/java/com/podzilla/courier/controllers/DeliveryTaskController.java +++ b/src/main/java/com/podzilla/courier/controllers/DeliveryTaskController.java @@ -21,48 +21,67 @@ public class DeliveryTaskController { private final DeliveryTaskService deliveryTaskService; - private static final Logger logger = LoggerFactory.getLogger(DeliveryTaskController.class); + private static final Logger logger = + LoggerFactory.getLogger(DeliveryTaskController.class); public DeliveryTaskController(DeliveryTaskService deliveryTaskService) { this.deliveryTaskService = deliveryTaskService; } @PostMapping - @Operation(summary = "Create delivery task", description = "Creates a new delivery task") - @ApiResponse(responseCode = "200", description = "Delivery task created successfully") + @Operation(summary = "Create delivery task", + description = "Creates a new delivery task") + @ApiResponse(responseCode = "200", + description = "Delivery task created successfully") public ResponseEntity createDeliveryTask( @RequestBody(description = "Delivery task creation details") - @org.springframework.web.bind.annotation.RequestBody CreateDeliveryTaskRequestDto deliveryTaskRequestDto) { + @org.springframework.web.bind.annotation.RequestBody + CreateDeliveryTaskRequestDto deliveryTaskRequestDto) { logger.info("Received request to create delivery task"); - return ResponseEntity.ok(deliveryTaskService.createDeliveryTask(deliveryTaskRequestDto)); + return ResponseEntity.ok( + deliveryTaskService.createDeliveryTask(deliveryTaskRequestDto)); } @PatchMapping("/{id}") - @Operation(summary = "Update delivery task status", description = "Updates the status of a delivery task") - @ApiResponse(responseCode = "200", description = "Status updated successfully") - @ApiResponse(responseCode = "404", description = "Delivery task not found") - public ResponseEntity> updateDeliveryTaskStatus( - @Parameter(description = "ID of the delivery task") @PathVariable String id, + @Operation(summary = "Update delivery task status", + description = "Updates the status of a delivery task") + @ApiResponse(responseCode = "200", + description = "Status updated successfully") + @ApiResponse(responseCode = "404", + description = "Delivery task not found") + public ResponseEntity> + updateDeliveryTaskStatus( + @Parameter(description = "ID of the delivery task") + @PathVariable String id, @RequestBody(description = "New status details") - @org.springframework.web.bind.annotation.RequestBody UpdateDeliveryStatusRequestDto statusDto) { + @org.springframework.web.bind.annotation.RequestBody + UpdateDeliveryStatusRequestDto statusDto) { logger.info("Received request to update delivery task with id {}", id); - return ResponseEntity.ok(deliveryTaskService.updateDeliveryTaskStatus(id, statusDto.getStatus())); + return ResponseEntity.ok( + deliveryTaskService.updateDeliveryTaskStatus( + id, statusDto.getStatus())); } @GetMapping - @Operation(summary = "Get all delivery tasks", description = "Retrieves all delivery tasks") - @ApiResponse(responseCode = "200", description = "Successfully retrieved all tasks") + @Operation(summary = "Get all delivery tasks", + description = "Retrieves all delivery tasks") + @ApiResponse(responseCode = "200", + description = "Successfully retrieved all tasks") public ResponseEntity> getAllDeliveryTasks() { logger.info("Received request to get all delivery tasks"); return ResponseEntity.ok(deliveryTaskService.getAllDeliveryTasks()); } @GetMapping("/{id}") - @Operation(summary = "Get delivery task by ID", description = "Retrieves a specific delivery task") - @ApiResponse(responseCode = "200", description = "Delivery task found") - @ApiResponse(responseCode = "404", description = "Delivery task not found") + @Operation(summary = "Get delivery task by ID", + description = "Retrieves a specific delivery task") + @ApiResponse(responseCode = "200", + description = "Delivery task found") + @ApiResponse(responseCode = "404", + description = "Delivery task not found") public ResponseEntity getDeliveryTaskById( - @Parameter(description = "ID of the delivery task") @PathVariable String id) { + @Parameter(description = "ID of the delivery task") + @PathVariable String id) { logger.info("Received request to get delivery task with id {}", id); return deliveryTaskService.getDeliveryTaskById(id) .map(ResponseEntity::ok) @@ -70,90 +89,140 @@ public ResponseEntity getDeliveryTaskById( } @GetMapping("/courier/{courierId}") - @Operation(summary = "Get tasks by courier ID", description = "Retrieves delivery tasks for a specific courier") - @ApiResponse(responseCode = "200", description = "Tasks retrieved successfully") - public ResponseEntity> getDeliveryTasksByCourierId( - @Parameter(description = "ID of the courier") @PathVariable String courierId) { - logger.info("Received request to get delivery task with courier id {}", courierId); - return ResponseEntity.ok(deliveryTaskService.getDeliveryTasksByCourierId(courierId)); + @Operation(summary = "Get tasks by courier ID", + description = "Retrieves delivery tasks for a specific courier") + @ApiResponse(responseCode = "200", + description = "Tasks retrieved successfully") + public ResponseEntity> + getDeliveryTasksByCourierId( + @Parameter(description = "ID of the courier") + @PathVariable String courierId) { + logger.info("Received request to get delivery task with courier id {}", + courierId); + return ResponseEntity.ok( + deliveryTaskService.getDeliveryTasksByCourierId(courierId)); } @GetMapping("/status/{status}") - @Operation(summary = "Get tasks by status", description = "Retrieves delivery tasks filtered by status") - @ApiResponse(responseCode = "200", description = "Tasks retrieved successfully") - public ResponseEntity> getDeliveryTasksByStatus( - @Parameter(description = "Delivery status filter") @PathVariable DeliveryStatus status) { - logger.info("Received request to get delivery task with status {}", status); - return ResponseEntity.ok(deliveryTaskService.getDeliveryTasksByStatus(status)); + @Operation(summary = "Get tasks by status", + description = "Retrieves delivery tasks filtered by status") + @ApiResponse(responseCode = "200", + description = "Tasks retrieved successfully") + public ResponseEntity> + getDeliveryTasksByStatus( + @Parameter(description = "Delivery status filter") + @PathVariable DeliveryStatus status) { + logger.info("Received request to get delivery task with status {}", + status); + return ResponseEntity.ok( + deliveryTaskService.getDeliveryTasksByStatus(status)); } @GetMapping("/order/{orderId}") - @Operation(summary = "Get tasks by order ID", description = "Retrieves delivery tasks for a specific order") - @ApiResponse(responseCode = "200", description = "Tasks retrieved successfully") - public ResponseEntity> getDeliveryTasksByOrderId( - @Parameter(description = "ID of the order") @PathVariable String orderId) { - logger.info("Received request to get delivery task with order id {}", orderId); - return ResponseEntity.ok(deliveryTaskService.getDeliveryTasksByOrderId(orderId)); + @Operation(summary = "Get tasks by order ID", + description = "Retrieves delivery tasks for a specific order") + @ApiResponse(responseCode = "200", + description = "Tasks retrieved successfully") + public ResponseEntity> + getDeliveryTasksByOrderId( + @Parameter(description = "ID of the order") + @PathVariable String orderId) { + logger.info("Received request to get delivery task with order id {}", + orderId); + return ResponseEntity.ok( + deliveryTaskService.getDeliveryTasksByOrderId(orderId)); } @GetMapping("/{id}/location") - @Operation(summary = "Get task location", description = "Retrieves coordinates of a delivery task") - @ApiResponse(responseCode = "200", description = "Location retrieved successfully") - @ApiResponse(responseCode = "404", description = "Task not found") + @Operation(summary = "Get task location", + description = "Retrieves coordinates of a delivery task") + @ApiResponse(responseCode = "200", + description = "Location retrieved successfully") + @ApiResponse(responseCode = "404", + description = "Task not found") public ResponseEntity> getDeliveryTaskLocation( - @Parameter(description = "ID of the delivery task") @PathVariable String id) { - logger.info("Received request to get the location of delivery task with id {}", id); - return ResponseEntity.ok(deliveryTaskService.getDeliveryTaskLocation(id)); + @Parameter(description = "ID of the delivery task") + @PathVariable String id) { + logger.info("Received request to get the location of delivery task " + + "with id {}", id); + return ResponseEntity.ok( + deliveryTaskService.getDeliveryTaskLocation(id)); } @PatchMapping("/{id}/location") - @Operation(summary = "Update task location", description = "Updates coordinates of a delivery task") - @ApiResponse(responseCode = "200", description = "Location updated successfully") + @Operation(summary = "Update task location", + description = "Updates coordinates of a delivery task") + @ApiResponse(responseCode = "200", + description = "Location updated successfully") public ResponseEntity updateDeliveryTaskLocation( - @Parameter(description = "ID of the delivery task") @PathVariable String id, + @Parameter(description = "ID of the delivery task") + @PathVariable String id, @RequestBody(description = "New coordinates data") - @org.springframework.web.bind.annotation.RequestBody LocationUpdateDto locationUpdateDto) { - logger.info("Received request to update the location of delivery task with id {}", id); - return ResponseEntity.ok(deliveryTaskService.updateDeliveryTaskLocation( - id, locationUpdateDto.getLatitude(), locationUpdateDto.getLongitude())); + @org.springframework.web.bind.annotation.RequestBody + LocationUpdateDto locationUpdateDto) { + logger.info("Received request to update the location of delivery " + + "task with id {}", id); + return ResponseEntity.ok( + deliveryTaskService.updateDeliveryTaskLocation( + id, + locationUpdateDto.getLatitude(), + locationUpdateDto.getLongitude())); } @PatchMapping("/{id}/cancel") - @Operation(summary = "Cancel delivery task", description = "Cancels a delivery task with a reason") - @ApiResponse(responseCode = "200", description = "Task cancelled successfully") + @Operation(summary = "Cancel delivery task", + description = "Cancels a delivery task with a reason") + @ApiResponse(responseCode = "200", + description = "Task cancelled successfully") public ResponseEntity cancelDeliveryTask( - @Parameter(description = "ID of the delivery task") @PathVariable String id, + @Parameter(description = "ID of the delivery task") + @PathVariable String id, @RequestBody(description = "Cancellation details") - @org.springframework.web.bind.annotation.RequestBody CancelDeliveryTaskRequestDto cancelTaskDto) { + @org.springframework.web.bind.annotation.RequestBody + CancelDeliveryTaskRequestDto cancelTaskDto) { logger.info("Received request to cancel delivery task with id {}", id); - return ResponseEntity.ok(deliveryTaskService.cancelDeliveryTask(id, cancelTaskDto.cancellationReason())); + return ResponseEntity.ok( + deliveryTaskService.cancelDeliveryTask( + id, cancelTaskDto.cancellationReason())); } @PatchMapping("/{id}/rate") - @Operation(summary = "Submit courier rating", description = "Submits a rating for the courier's performance") - @ApiResponse(responseCode = "200", description = "Rating submitted successfully") + @Operation(summary = "Submit courier rating", + description = "Submits a rating for the courier's performance") + @ApiResponse(responseCode = "200", + description = "Rating submitted successfully") public ResponseEntity submitCourierRating( - @Parameter(description = "ID of the delivery task") @PathVariable String id, + @Parameter(description = "ID of the delivery task") + @PathVariable String id, @RequestBody(description = "Rating details") - @org.springframework.web.bind.annotation.RequestBody SubmitCourierRatingRequestDto ratingDto) { - return ResponseEntity.ok(deliveryTaskService.submitCourierRating(id, ratingDto.getRating())); + @org.springframework.web.bind.annotation.RequestBody + SubmitCourierRatingRequestDto ratingDto) { + return ResponseEntity.ok( + deliveryTaskService.submitCourierRating(id, ratingDto.getRating())); } @DeleteMapping("/{id}") - @Operation(summary = "Delete delivery task", description = "Permanently removes a delivery task") - @ApiResponse(responseCode = "200", description = "Task deleted successfully") + @Operation(summary = "Delete delivery task", + description = "Permanently removes a delivery task") + @ApiResponse(responseCode = "200", + description = "Task deleted successfully") public ResponseEntity deleteDeliveryTask( - @Parameter(description = "ID of the delivery task") @PathVariable String id) { + @Parameter(description = "ID of the delivery task") + @PathVariable String id) { logger.info("Received request to delete delivery task with id {}", id); return ResponseEntity.ok(deliveryTaskService.deleteDeliveryTask(id)); } @PutMapping("/{id}/otp") - @Operation(summary = "Update OTP", description = "Updates the One-Time Password for a delivery task") - @ApiResponse(responseCode = "200", description = "OTP updated successfully") - @ApiResponse(responseCode = "404", description = "Task not found") + @Operation(summary = "Update OTP", + description = "Updates the One-Time Password for a delivery task") + @ApiResponse(responseCode = "200", + description = "OTP updated successfully") + @ApiResponse(responseCode = "404", + description = "Task not found") public ResponseEntity updateOtp( - @Parameter(description = "ID of the delivery task") @PathVariable String id, + @Parameter(description = "ID of the delivery task") + @PathVariable String id, @RequestBody(description = "New OTP value") @org.springframework.web.bind.annotation.RequestBody String otp) { return deliveryTaskService.updateOtp(id, otp) @@ -162,11 +231,15 @@ public ResponseEntity updateOtp( } @PutMapping("/{id}/otp-confirmation") - @Operation(summary = "Confirm OTP", description = "Validates the One-Time Password for a delivery task") - @ApiResponse(responseCode = "200", description = "OTP confirmed successfully") - @ApiResponse(responseCode = "404", description = "Invalid OTP or task not found") + @Operation(summary = "Confirm OTP", + description = "Validates the One-Time Password for a delivery task") + @ApiResponse(responseCode = "200", + description = "OTP confirmed successfully") + @ApiResponse(responseCode = "404", + description = "Invalid OTP or task not found") public ResponseEntity confirmOTP( - @Parameter(description = "ID of the delivery task") @PathVariable String id, + @Parameter(description = "ID of the delivery task") + @PathVariable String id, @RequestBody(description = "OTP to validate") @org.springframework.web.bind.annotation.RequestBody String otp) { return deliveryTaskService.confirmOTP(id, otp) From cf4475af6ed4c8a5a9bd6b028c5075c436cae778 Mon Sep 17 00:00:00 2001 From: omar mohammed Date: Sun, 11 May 2025 14:06:57 +0300 Subject: [PATCH 6/6] fix controllers style error --- .../controllers/CourierController.java | 38 +-- .../controllers/DeliveryTaskController.java | 253 +++++++----------- 2 files changed, 127 insertions(+), 164 deletions(-) diff --git a/src/main/java/com/podzilla/courier/controllers/CourierController.java b/src/main/java/com/podzilla/courier/controllers/CourierController.java index 2ea78e8..5ebfa56 100644 --- a/src/main/java/com/podzilla/courier/controllers/CourierController.java +++ b/src/main/java/com/podzilla/courier/controllers/CourierController.java @@ -1,6 +1,8 @@ package com.podzilla.courier.controllers; -import com.podzilla.courier.dtos.couriers.*; +import com.podzilla.courier.dtos.couriers.CourierResponseDto; +import com.podzilla.courier.dtos.couriers.CreateCourierRequestDto; +import com.podzilla.courier.dtos.couriers.UpdateCourierRequestDto; import com.podzilla.courier.services.CourierService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -9,7 +11,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.PathVariable; import java.util.List; @@ -17,10 +25,10 @@ @RequestMapping("/couriers") public class CourierController { private final CourierService courierService; - private static final Logger logger = + private static final Logger LOGGER = LoggerFactory.getLogger(CourierController.class); - public CourierController(CourierService courierService) { + public CourierController(final CourierService courierService) { this.courierService = courierService; } @@ -30,7 +38,7 @@ public CourierController(CourierService courierService) { @ApiResponse(responseCode = "200", description = "Successfully retrieved list of couriers") public ResponseEntity> getAllCouriers() { - logger.info("Received request to get all couriers"); + LOGGER.info("Received request to get all couriers"); return ResponseEntity.ok(courierService.getAllCouriers()); } @@ -43,8 +51,8 @@ public ResponseEntity> getAllCouriers() { description = "Courier not found") public ResponseEntity getCourierById( @Parameter(description = "ID of the courier to retrieve") - @PathVariable String id) { - logger.info("Received request to get courier with id {}", id); + @PathVariable final String id) { + LOGGER.info("Received request to get courier with id {}", id); return courierService.getCourierById(id) .map(ResponseEntity::ok) .orElse(ResponseEntity.notFound().build()); @@ -58,8 +66,8 @@ public ResponseEntity getCourierById( public ResponseEntity createCourier( @RequestBody(description = "Details of the courier to create") @org.springframework.web.bind.annotation.RequestBody - CreateCourierRequestDto courier) { - logger.info("Received request to add courier"); + final CreateCourierRequestDto courier) { + LOGGER.info("Received request to add courier"); return ResponseEntity.ok(courierService.createCourier(courier)); } @@ -72,11 +80,11 @@ public ResponseEntity createCourier( description = "Courier not found") public ResponseEntity updateCourier( @Parameter(description = "ID of the courier to update") - @PathVariable String id, + @PathVariable final String id, @RequestBody(description = "Updated courier details") @org.springframework.web.bind.annotation.RequestBody - UpdateCourierRequestDto courier) { - logger.info("Received request to update courier with id {}", id); + final UpdateCourierRequestDto courier) { + LOGGER.info("Received request to update courier with id {}", id); return courierService.updateCourier(id, courier) .map(ResponseEntity::ok) .orElse(ResponseEntity.notFound().build()); @@ -91,10 +99,10 @@ public ResponseEntity updateCourier( description = "Courier not found") public ResponseEntity deleteCourier( @Parameter(description = "ID of the courier to delete") - @PathVariable String id) { - logger.info("Received request to delete courier with id {}", id); + @PathVariable final String id) { + LOGGER.info("Received request to delete courier with id {}", id); return courierService.deleteCourier(id) .map(ResponseEntity::ok) .orElse(ResponseEntity.notFound().build()); } -} \ No newline at end of file +} diff --git a/src/main/java/com/podzilla/courier/controllers/DeliveryTaskController.java b/src/main/java/com/podzilla/courier/controllers/DeliveryTaskController.java index 621cc9e..27997b8 100644 --- a/src/main/java/com/podzilla/courier/controllers/DeliveryTaskController.java +++ b/src/main/java/com/podzilla/courier/controllers/DeliveryTaskController.java @@ -1,249 +1,204 @@ package com.podzilla.courier.controllers; -import com.podzilla.courier.dtos.delivery_tasks.*; +import com.podzilla.courier.dtos.delivery_tasks.SubmitCourierRatingResponseDto; +import com.podzilla.courier.dtos.delivery_tasks.SubmitCourierRatingRequestDto; +import com.podzilla.courier.dtos.delivery_tasks.CancelDeliveryTaskRequestDto; +import com.podzilla.courier.dtos.delivery_tasks.LocationUpdateDto; +import com.podzilla.courier.dtos.delivery_tasks.CancelDeliveryTaskResponseDto; +import com.podzilla.courier.dtos.delivery_tasks.CreateDeliveryTaskRequestDto; +import com.podzilla.courier.dtos.delivery_tasks.DeliveryTaskResponseDto; +import com.podzilla.courier.dtos.delivery_tasks.UpdateDeliveryStatusRequestDto; +import com.podzilla.courier.models.DeliveryStatus; +import com.podzilla.courier.services.DeliveryTaskService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.parameters.RequestBody; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import java.util.List; +import java.util.Optional; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.util.Pair; -import com.podzilla.courier.models.DeliveryStatus; -import com.podzilla.courier.services.DeliveryTaskService; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import java.util.List; -import java.util.Optional; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/delivery-tasks") public class DeliveryTaskController { + private static final Logger LOGGER = LoggerFactory.getLogger(DeliveryTaskController.class); + private final DeliveryTaskService deliveryTaskService; - private static final Logger logger = - LoggerFactory.getLogger(DeliveryTaskController.class); - public DeliveryTaskController(DeliveryTaskService deliveryTaskService) { + public DeliveryTaskController(final DeliveryTaskService deliveryTaskService) { this.deliveryTaskService = deliveryTaskService; } @PostMapping - @Operation(summary = "Create delivery task", - description = "Creates a new delivery task") - @ApiResponse(responseCode = "200", - description = "Delivery task created successfully") + @Operation(summary = "Create delivery task", description = "Creates a new delivery task") + @ApiResponse(responseCode = "200", description = "Delivery task created successfully") public ResponseEntity createDeliveryTask( @RequestBody(description = "Delivery task creation details") - @org.springframework.web.bind.annotation.RequestBody - CreateDeliveryTaskRequestDto deliveryTaskRequestDto) { - logger.info("Received request to create delivery task"); - return ResponseEntity.ok( - deliveryTaskService.createDeliveryTask(deliveryTaskRequestDto)); + @org.springframework.web.bind.annotation.RequestBody final CreateDeliveryTaskRequestDto requestDto) { + LOGGER.info("Received request to create delivery task"); + return ResponseEntity.ok(deliveryTaskService.createDeliveryTask(requestDto)); } @PatchMapping("/{id}") - @Operation(summary = "Update delivery task status", - description = "Updates the status of a delivery task") - @ApiResponse(responseCode = "200", - description = "Status updated successfully") - @ApiResponse(responseCode = "404", - description = "Delivery task not found") - public ResponseEntity> - updateDeliveryTaskStatus( + @Operation(summary = "Update delivery task status", description = "Updates the status of a delivery task") + @ApiResponse(responseCode = "200", description = "Status updated successfully") + @ApiResponse(responseCode = "404", description = "Delivery task not found") + public ResponseEntity> updateDeliveryTaskStatus( @Parameter(description = "ID of the delivery task") - @PathVariable String id, + @PathVariable final String id, @RequestBody(description = "New status details") - @org.springframework.web.bind.annotation.RequestBody - UpdateDeliveryStatusRequestDto statusDto) { - logger.info("Received request to update delivery task with id {}", id); - return ResponseEntity.ok( - deliveryTaskService.updateDeliveryTaskStatus( - id, statusDto.getStatus())); + @org.springframework.web.bind.annotation.RequestBody final UpdateDeliveryStatusRequestDto statusDto) { + LOGGER.info("Received request to update delivery task with id {}", id); + return ResponseEntity.ok(deliveryTaskService.updateDeliveryTaskStatus(id, statusDto.getStatus())); } @GetMapping - @Operation(summary = "Get all delivery tasks", - description = "Retrieves all delivery tasks") - @ApiResponse(responseCode = "200", - description = "Successfully retrieved all tasks") + @Operation(summary = "Get all delivery tasks", description = "Retrieves all delivery tasks") + @ApiResponse(responseCode = "200", description = "Successfully retrieved all tasks") public ResponseEntity> getAllDeliveryTasks() { - logger.info("Received request to get all delivery tasks"); + LOGGER.info("Received request to get all delivery tasks"); return ResponseEntity.ok(deliveryTaskService.getAllDeliveryTasks()); } @GetMapping("/{id}") - @Operation(summary = "Get delivery task by ID", - description = "Retrieves a specific delivery task") - @ApiResponse(responseCode = "200", - description = "Delivery task found") - @ApiResponse(responseCode = "404", - description = "Delivery task not found") + @Operation(summary = "Get delivery task by ID", description = "Retrieves a specific delivery task") + @ApiResponse(responseCode = "200", description = "Delivery task found") + @ApiResponse(responseCode = "404", description = "Delivery task not found") public ResponseEntity getDeliveryTaskById( @Parameter(description = "ID of the delivery task") - @PathVariable String id) { - logger.info("Received request to get delivery task with id {}", id); + @PathVariable final String id) { + LOGGER.info("Received request to get delivery task with id {}", id); return deliveryTaskService.getDeliveryTaskById(id) .map(ResponseEntity::ok) .orElse(ResponseEntity.notFound().build()); } @GetMapping("/courier/{courierId}") - @Operation(summary = "Get tasks by courier ID", - description = "Retrieves delivery tasks for a specific courier") - @ApiResponse(responseCode = "200", - description = "Tasks retrieved successfully") - public ResponseEntity> - getDeliveryTasksByCourierId( + @Operation(summary = "Get tasks by courier ID", description = "Retrieves delivery tasks for a specific courier") + @ApiResponse(responseCode = "200", description = "Tasks retrieved successfully") + public ResponseEntity> getDeliveryTasksByCourierId( @Parameter(description = "ID of the courier") - @PathVariable String courierId) { - logger.info("Received request to get delivery task with courier id {}", - courierId); - return ResponseEntity.ok( - deliveryTaskService.getDeliveryTasksByCourierId(courierId)); + @PathVariable final String courierId) { + LOGGER.info("Received request to get delivery task with courier id {}", courierId); + return ResponseEntity.ok(deliveryTaskService.getDeliveryTasksByCourierId(courierId)); } @GetMapping("/status/{status}") - @Operation(summary = "Get tasks by status", - description = "Retrieves delivery tasks filtered by status") - @ApiResponse(responseCode = "200", - description = "Tasks retrieved successfully") - public ResponseEntity> - getDeliveryTasksByStatus( + @Operation(summary = "Get tasks by status", description = "Retrieves delivery tasks filtered by status") + @ApiResponse(responseCode = "200", description = "Tasks retrieved successfully") + public ResponseEntity> getDeliveryTasksByStatus( @Parameter(description = "Delivery status filter") - @PathVariable DeliveryStatus status) { - logger.info("Received request to get delivery task with status {}", - status); - return ResponseEntity.ok( - deliveryTaskService.getDeliveryTasksByStatus(status)); + @PathVariable final DeliveryStatus status) { + LOGGER.info("Received request to get delivery task with status {}", status); + return ResponseEntity.ok(deliveryTaskService.getDeliveryTasksByStatus(status)); } @GetMapping("/order/{orderId}") - @Operation(summary = "Get tasks by order ID", - description = "Retrieves delivery tasks for a specific order") - @ApiResponse(responseCode = "200", - description = "Tasks retrieved successfully") - public ResponseEntity> - getDeliveryTasksByOrderId( + @Operation(summary = "Get tasks by order ID", description = "Retrieves delivery tasks for a specific order") + @ApiResponse(responseCode = "200", description = "Tasks retrieved successfully") + public ResponseEntity> getDeliveryTasksByOrderId( @Parameter(description = "ID of the order") - @PathVariable String orderId) { - logger.info("Received request to get delivery task with order id {}", - orderId); - return ResponseEntity.ok( - deliveryTaskService.getDeliveryTasksByOrderId(orderId)); + @PathVariable final String orderId) { + LOGGER.info("Received request to get delivery task with order id {}", orderId); + return ResponseEntity.ok(deliveryTaskService.getDeliveryTasksByOrderId(orderId)); } @GetMapping("/{id}/location") - @Operation(summary = "Get task location", - description = "Retrieves coordinates of a delivery task") - @ApiResponse(responseCode = "200", - description = "Location retrieved successfully") - @ApiResponse(responseCode = "404", - description = "Task not found") + @Operation(summary = "Get task location", description = "Retrieves coordinates of a delivery task") + @ApiResponse(responseCode = "200", description = "Location retrieved successfully") + @ApiResponse(responseCode = "404", description = "Task not found") public ResponseEntity> getDeliveryTaskLocation( @Parameter(description = "ID of the delivery task") - @PathVariable String id) { - logger.info("Received request to get the location of delivery task " + - "with id {}", id); - return ResponseEntity.ok( - deliveryTaskService.getDeliveryTaskLocation(id)); + @PathVariable final String id) { + LOGGER.info("Received request to get the location of delivery task with id {}", id); + return ResponseEntity.ok(deliveryTaskService.getDeliveryTaskLocation(id)); } @PatchMapping("/{id}/location") - @Operation(summary = "Update task location", - description = "Updates coordinates of a delivery task") - @ApiResponse(responseCode = "200", - description = "Location updated successfully") + @Operation(summary = "Update task location", description = "Updates coordinates of a delivery task") + @ApiResponse(responseCode = "200", description = "Location updated successfully") public ResponseEntity updateDeliveryTaskLocation( @Parameter(description = "ID of the delivery task") - @PathVariable String id, + @PathVariable final String id, @RequestBody(description = "New coordinates data") - @org.springframework.web.bind.annotation.RequestBody - LocationUpdateDto locationUpdateDto) { - logger.info("Received request to update the location of delivery " + - "task with id {}", id); - return ResponseEntity.ok( - deliveryTaskService.updateDeliveryTaskLocation( - id, - locationUpdateDto.getLatitude(), - locationUpdateDto.getLongitude())); + @org.springframework.web.bind.annotation.RequestBody final LocationUpdateDto locationUpdateDto) { + LOGGER.info("Received request to update the location of delivery task with id {}", id); + return ResponseEntity.ok(deliveryTaskService.updateDeliveryTaskLocation( + id, + locationUpdateDto.getLatitude(), + locationUpdateDto.getLongitude())); } @PatchMapping("/{id}/cancel") - @Operation(summary = "Cancel delivery task", - description = "Cancels a delivery task with a reason") - @ApiResponse(responseCode = "200", - description = "Task cancelled successfully") + @Operation(summary = "Cancel delivery task", description = "Cancels a delivery task with a reason") + @ApiResponse(responseCode = "200", description = "Task cancelled successfully") public ResponseEntity cancelDeliveryTask( @Parameter(description = "ID of the delivery task") - @PathVariable String id, + @PathVariable final String id, @RequestBody(description = "Cancellation details") - @org.springframework.web.bind.annotation.RequestBody - CancelDeliveryTaskRequestDto cancelTaskDto) { - logger.info("Received request to cancel delivery task with id {}", id); - return ResponseEntity.ok( - deliveryTaskService.cancelDeliveryTask( - id, cancelTaskDto.cancellationReason())); + @org.springframework.web.bind.annotation.RequestBody final CancelDeliveryTaskRequestDto cancelTaskDto) { + LOGGER.info("Received request to cancel delivery task with id {}", id); + return ResponseEntity.ok(deliveryTaskService.cancelDeliveryTask(id, cancelTaskDto.cancellationReason())); } @PatchMapping("/{id}/rate") - @Operation(summary = "Submit courier rating", - description = "Submits a rating for the courier's performance") - @ApiResponse(responseCode = "200", - description = "Rating submitted successfully") + @Operation(summary = "Submit courier rating", description = "Submits a rating for the courier's performance") + @ApiResponse(responseCode = "200", description = "Rating submitted successfully") public ResponseEntity submitCourierRating( @Parameter(description = "ID of the delivery task") - @PathVariable String id, + @PathVariable final String id, @RequestBody(description = "Rating details") - @org.springframework.web.bind.annotation.RequestBody - SubmitCourierRatingRequestDto ratingDto) { - return ResponseEntity.ok( - deliveryTaskService.submitCourierRating(id, ratingDto.getRating())); + @org.springframework.web.bind.annotation.RequestBody final SubmitCourierRatingRequestDto ratingDto) { + return ResponseEntity.ok(deliveryTaskService.submitCourierRating(id, ratingDto.getRating())); } @DeleteMapping("/{id}") - @Operation(summary = "Delete delivery task", - description = "Permanently removes a delivery task") - @ApiResponse(responseCode = "200", - description = "Task deleted successfully") + @Operation(summary = "Delete delivery task", description = "Permanently removes a delivery task") + @ApiResponse(responseCode = "200", description = "Task deleted successfully") public ResponseEntity deleteDeliveryTask( @Parameter(description = "ID of the delivery task") - @PathVariable String id) { - logger.info("Received request to delete delivery task with id {}", id); + @PathVariable final String id) { + LOGGER.info("Received request to delete delivery task with id {}", id); return ResponseEntity.ok(deliveryTaskService.deleteDeliveryTask(id)); } @PutMapping("/{id}/otp") - @Operation(summary = "Update OTP", - description = "Updates the One-Time Password for a delivery task") - @ApiResponse(responseCode = "200", - description = "OTP updated successfully") - @ApiResponse(responseCode = "404", - description = "Task not found") + @Operation(summary = "Update OTP", description = "Updates the One-Time Password for a delivery task") + @ApiResponse(responseCode = "200", description = "OTP updated successfully") + @ApiResponse(responseCode = "404", description = "Task not found") public ResponseEntity updateOtp( @Parameter(description = "ID of the delivery task") - @PathVariable String id, + @PathVariable final String id, @RequestBody(description = "New OTP value") - @org.springframework.web.bind.annotation.RequestBody String otp) { + @org.springframework.web.bind.annotation.RequestBody final String otp) { return deliveryTaskService.updateOtp(id, otp) .map(ResponseEntity::ok) .orElse(ResponseEntity.notFound().build()); } @PutMapping("/{id}/otp-confirmation") - @Operation(summary = "Confirm OTP", - description = "Validates the One-Time Password for a delivery task") - @ApiResponse(responseCode = "200", - description = "OTP confirmed successfully") - @ApiResponse(responseCode = "404", - description = "Invalid OTP or task not found") + @Operation(summary = "Confirm OTP", description = "Validates the One-Time Password for a delivery task") + @ApiResponse(responseCode = "200", description = "OTP confirmed successfully") + @ApiResponse(responseCode = "404", description = "Invalid OTP or task not found") public ResponseEntity confirmOTP( @Parameter(description = "ID of the delivery task") - @PathVariable String id, + @PathVariable final String id, @RequestBody(description = "OTP to validate") - @org.springframework.web.bind.annotation.RequestBody String otp) { + @org.springframework.web.bind.annotation.RequestBody final String otp) { return deliveryTaskService.confirmOTP(id, otp) .map(ResponseEntity::ok) .orElse(ResponseEntity.notFound().build()); } -} \ No newline at end of file +}