exercises

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

shipment.rs (1122B)


      1 //! Shipment tracking models
      2 
      3 use chrono::{DateTime, NaiveDate, Utc};
      4 use serde::{Deserialize, Serialize};
      5 use sqlx::FromRow;
      6 use uuid::Uuid;
      7 
      8 /// Shipment entity
      9 #[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
     10 pub struct Shipment {
     11     pub id: i32,
     12     pub uuid: Uuid,
     13 
     14     pub order_id: i32,
     15 
     16     // Shipping carrier
     17     pub carrier: String,
     18     pub tracking_number: Option<String>,
     19 
     20     // Status
     21     pub status: String,
     22 
     23     // Delivery dates
     24     pub estimated_delivery_date: Option<NaiveDate>,
     25     pub actual_delivery_date: Option<NaiveDate>,
     26 
     27     pub shipped_at: Option<DateTime<Utc>>,
     28     pub delivered_at: Option<DateTime<Utc>>,
     29     pub created_at: DateTime<Utc>,
     30     pub updated_at: DateTime<Utc>,
     31 }
     32 
     33 /// Request to create a shipment
     34 #[derive(Debug, Deserialize)]
     35 pub struct CreateShipmentRequest {
     36     pub carrier: String,
     37     pub tracking_number: Option<String>,
     38     pub estimated_delivery_date: Option<NaiveDate>,
     39 }
     40 
     41 /// Request to update shipment status
     42 #[derive(Debug, Deserialize)]
     43 pub struct UpdateShipmentStatusRequest {
     44     pub status: String,
     45     pub actual_delivery_date: Option<NaiveDate>,
     46 }