Skip to main content

backbone_pos/presentation/dto/
mod.rs

1//! DTOs (Data Transfer Objects)
2//!
3//! Generated by metaphor-schema. Do not edit manually.
4//!
5//! This module provides DTOs for the presentation layer,
6//! with validation and OpenAPI schema support.
7
8pub mod pos_closing_entry_dto;
9pub mod pos_invoice_dto;
10pub mod pos_invoice_item_dto;
11pub mod pos_payment_dto;
12pub mod pos_profile_dto;
13pub mod pos_opening_entry_dto;
14pub mod pos_cash_movement_dto;
15pub mod pos_discount_dto;
16pub mod pos_manager_pin_dto;
17pub mod pos_floor_plan_dto;
18pub mod pos_table_dto;
19
20// Re-exports
21pub use pos_closing_entry_dto::{
22    CreatePosClosingEntryDto,
23    UpdatePosClosingEntryDto,
24    PatchPosClosingEntryDto,
25    PosClosingEntryResponseDto,
26    PosClosingEntryListResponseDto,
27    PosClosingEntrySummaryDto,
28};
29pub use pos_invoice_dto::{
30    CreatePosInvoiceDto,
31    UpdatePosInvoiceDto,
32    PatchPosInvoiceDto,
33    PosInvoiceResponseDto,
34    PosInvoiceListResponseDto,
35    PosInvoiceSummaryDto,
36};
37pub use pos_invoice_item_dto::{
38    CreatePosInvoiceItemDto,
39    UpdatePosInvoiceItemDto,
40    PatchPosInvoiceItemDto,
41    PosInvoiceItemResponseDto,
42    PosInvoiceItemListResponseDto,
43    PosInvoiceItemSummaryDto,
44};
45pub use pos_payment_dto::{
46    CreatePosPaymentDto,
47    UpdatePosPaymentDto,
48    PatchPosPaymentDto,
49    PosPaymentResponseDto,
50    PosPaymentListResponseDto,
51    PosPaymentSummaryDto,
52};
53pub use pos_profile_dto::{
54    CreatePosProfileDto,
55    UpdatePosProfileDto,
56    PatchPosProfileDto,
57    PosProfileResponseDto,
58    PosProfileListResponseDto,
59    PosProfileSummaryDto,
60};
61pub use pos_opening_entry_dto::{
62    CreatePosOpeningEntryDto,
63    UpdatePosOpeningEntryDto,
64    PatchPosOpeningEntryDto,
65    PosOpeningEntryResponseDto,
66    PosOpeningEntryListResponseDto,
67    PosOpeningEntrySummaryDto,
68};
69pub use pos_cash_movement_dto::{
70    CreatePosCashMovementDto,
71    UpdatePosCashMovementDto,
72    PatchPosCashMovementDto,
73    PosCashMovementResponseDto,
74    PosCashMovementListResponseDto,
75    PosCashMovementSummaryDto,
76};
77pub use pos_discount_dto::{
78    CreatePosDiscountDto,
79    UpdatePosDiscountDto,
80    PatchPosDiscountDto,
81    PosDiscountResponseDto,
82    PosDiscountListResponseDto,
83    PosDiscountSummaryDto,
84};
85pub use pos_manager_pin_dto::{
86    CreatePosManagerPinDto,
87    UpdatePosManagerPinDto,
88    PatchPosManagerPinDto,
89    PosManagerPinResponseDto,
90    PosManagerPinListResponseDto,
91    PosManagerPinSummaryDto,
92};
93pub use pos_floor_plan_dto::{
94    CreatePosFloorPlanDto,
95    UpdatePosFloorPlanDto,
96    PatchPosFloorPlanDto,
97    PosFloorPlanResponseDto,
98    PosFloorPlanListResponseDto,
99    PosFloorPlanSummaryDto,
100};
101pub use pos_table_dto::{
102    CreatePosTableDto,
103    UpdatePosTableDto,
104    PatchPosTableDto,
105    PosTableResponseDto,
106    PosTableListResponseDto,
107    PosTableSummaryDto,
108};
109
110// Common pagination types
111use serde::Serialize;
112
113#[cfg(feature = "openapi")]
114#[cfg(feature = "openapi")]
115use utoipa::ToSchema;
116
117/// Pagination parameters for list requests
118#[derive(Debug, Clone, Default, serde::Deserialize)]
119#[cfg_attr(feature = "openapi", derive(ToSchema))]
120pub struct PaginationParams {
121    /// Page number (1-indexed)
122    #[serde(default = "default_page")]
123    pub page: u32,
124    /// Items per page
125    #[serde(default = "default_per_page")]
126    pub per_page: u32,
127    /// Field to sort by
128    pub sort_by: Option<String>,
129    /// Sort order (asc/desc)
130    pub sort_order: Option<String>,
131}
132
133fn default_page() -> u32 { 1 }
134fn default_per_page() -> u32 { 20 }
135
136/// API response wrapper
137#[derive(Debug, Clone, Serialize)]
138#[cfg_attr(feature = "openapi", derive(ToSchema))]
139#[serde(rename_all = "camelCase")]
140pub struct ApiResponse<T> {
141    pub success: bool,
142    #[serde(skip_serializing_if = "Option::is_none")]
143    pub data: Option<T>,
144    #[serde(skip_serializing_if = "Option::is_none")]
145    pub error: Option<ApiError>,
146}
147
148#[derive(Debug, Clone, Serialize)]
149#[cfg_attr(feature = "openapi", derive(ToSchema))]
150pub struct ApiError {
151    pub code: String,
152    pub message: String,
153    #[serde(skip_serializing_if = "Option::is_none")]
154    pub details: Option<serde_json::Value>,
155}
156
157impl<T> ApiResponse<T> {
158    pub fn ok(data: T) -> Self {
159        Self { success: true, data: Some(data), error: None }
160    }
161
162    pub fn err(code: impl Into<String>, message: impl Into<String>) -> Self {
163        Self {
164            success: false,
165            data: None,
166            error: Some(ApiError {
167                code: code.into(),
168                message: message.into(),
169                details: None,
170            }),
171        }
172    }
173}