Skip to content

Commit

Permalink
refactor: convert to record
Browse files Browse the repository at this point in the history
  • Loading branch information
lcaohoanq committed Dec 8, 2024
1 parent a6d634e commit b6f345b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public ResponseEntity<?> confirmDelivery(@Valid @PathVariable long id,
try {
Order updatedOrder = orderService.updateOrderStatus(id,
OrderStatus.valueOf(
updateOrderStatusDTO.getStatus()));
updateOrderStatusDTO.status()));
return ResponseEntity.ok(toOrderResponse(updatedOrder));
} catch (Exception e) {
BaseResponse response = new BaseResponse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.Getter;

@Getter
public class UpdateOrderStatusDTO {
public record UpdateOrderStatusDTO(
@NotBlank(message = "Order status is required")
@Pattern(regexp = "PROCESSING|SHIPPING|DELIVERED|PENDING|CANCELLED|COMPLETED", message = "Status must be either PROCESSING, SHIPPING, DELIVERED, PENDING, CANCELLED or COMPLETED")
@JsonProperty("status")
String status;
}
String status
) {}

0 comments on commit b6f345b

Please sign in to comment.