created request and response dto

This commit is contained in:
2026-06-12 16:21:39 +03:00
parent 48422d3e62
commit 67403a8414
11 changed files with 168 additions and 0 deletions
@@ -0,0 +1,15 @@
package com.andwati.orders.dto.request;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import java.util.UUID;
public record CreateOrderItemRequest(
@NotNull(message = "productId is required")
UUID productId,
@Min(value = 1, message = "quantity must be at least 1")
int quantity
) {
}
@@ -0,0 +1,18 @@
package com.andwati.orders.dto.request;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import java.util.List;
public record CreateOrderRequest(
@NotBlank(message = "customerName is required")
@Size(min = 2, max = 120, message = "customerName must be between 2 and 120 characters")
String customerName,
@Valid
@Size(min = 1, message = "items must contain at least one item")
List<CreateOrderItemRequest> items
) {
}
@@ -0,0 +1,15 @@
package com.andwati.orders.dto.response;
import com.andwati.orders.model.OrderStatus;
import java.time.Instant;
import java.util.UUID;
public record CancelOrderResponse(
UUID id,
OrderStatus status,
Instant cancelledAt,
boolean stockRolledBack
) {
}
@@ -0,0 +1,12 @@
package com.andwati.orders.dto.response;
import java.time.Instant;
public record ErrorResponse(
String error,
String message,
Object details,
Instant timestamp,
String path
) {
}
@@ -0,0 +1,16 @@
package com.andwati.orders.dto.response;
import java.math.BigDecimal;
public record FareCalculationResponse(
BigDecimal distanceKm,
BigDecimal baseFare,
BigDecimal perKmRate,
BigDecimal surgeMultiplier,
BigDecimal minimumFare,
BigDecimal calculatedFare,
String currency,
String formula
) {
}
@@ -0,0 +1,19 @@
package com.andwati.orders.dto.response;
import com.andwati.orders.model.InventoryStatus;
import java.time.Instant;
import java.util.UUID;
public record InventoryItemResponse(
UUID productId,
String productName,
String sku,
int availableQuantity,
int reservedQuantity,
int reorderLevel,
InventoryStatus status,
Instant updatedAt
) {
}
@@ -0,0 +1,9 @@
package com.andwati.orders.dto.response;
import java.util.List;
public record LowStockInventoryResponse(
int threshold,
List<InventoryItemResponse> items
) {
}
@@ -0,0 +1,13 @@
package com.andwati.orders.dto.response;
import java.math.BigDecimal;
import java.util.UUID;
public record OrderItemResponse(
UUID productId,
String productName,
int quantity,
BigDecimal unitPrice,
BigDecimal lineTotal
) {
}
@@ -0,0 +1,20 @@
package com.andwati.orders.dto.response;
import com.andwati.orders.model.OrderStatus;
import java.math.BigDecimal;
import java.time.Instant;
import java.util.List;
import java.util.UUID;
public record OrderResponse(
UUID id,
String customerName,
OrderStatus status,
List<OrderItemResponse> items,
BigDecimal totalAmount,
String currency,
Instant createdAt,
Instant cancelledAt
) {
}
@@ -0,0 +1,19 @@
package com.andwati.orders.dto.response;
import com.andwati.orders.model.OrderStatus;
import java.math.BigDecimal;
import java.time.Instant;
import java.util.UUID;
public record OrderSummaryResponse(
UUID id,
String customerName,
OrderStatus status,
BigDecimal totalAmount,
String currency,
int itemCount,
Instant createdAt,
Instant cancelledAt
) {
}
@@ -0,0 +1,12 @@
package com.andwati.orders.dto.response;
import java.util.List;
public record PageResponse<T>(
List<T> items,
int page,
int size,
long totalItems,
int totalPages
) {
}