use fmodel_rust::Identifier;
#[derive(Debug, Clone, PartialEq)]
#[allow(dead_code)]
pub struct OrderState {
pub order_id: u32,
pub customer_name: String,
pub items: Vec<String>,
pub is_cancelled: bool,
}
#[derive(Debug, Clone, PartialEq)]
#[allow(dead_code)]
pub struct OrderViewState {
pub order_id: u32,
pub customer_name: String,
pub items: Vec<String>,
pub is_cancelled: bool,
}
#[derive(Debug, Clone, PartialEq)]
#[allow(dead_code)]
pub struct OrderView2State {
pub order_id: u32,
pub customer_name: String,
pub items: Vec<String>,
pub is_cancelled: bool,
}
#[derive(Debug, Clone, PartialEq)]
#[allow(dead_code)]
pub enum OrderCommand {
Create(CreateOrderCommand),
Update(UpdateOrderCommand),
Cancel(CancelOrderCommand),
}
#[derive(Debug, Clone, PartialEq)]
pub struct CreateOrderCommand {
pub order_id: u32,
pub customer_name: String,
pub items: Vec<String>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateOrderCommand {
pub order_id: u32,
pub new_items: Vec<String>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct CancelOrderCommand {
pub order_id: u32,
}
impl Identifier for OrderCommand {
#[allow(dead_code)]
fn identifier(&self) -> String {
match self {
OrderCommand::Create(c) => c.order_id.to_string(),
OrderCommand::Update(c) => c.order_id.to_string(),
OrderCommand::Cancel(c) => c.order_id.to_string(),
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[allow(dead_code)]
pub enum OrderEvent {
Created(OrderCreatedEvent),
Updated(OrderUpdatedEvent),
Cancelled(OrderCancelledEvent),
}
#[derive(Debug, Clone, PartialEq)]
pub struct OrderCreatedEvent {
pub order_id: u32,
pub customer_name: String,
pub items: Vec<String>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct OrderUpdatedEvent {
pub order_id: u32,
pub updated_items: Vec<String>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct OrderCancelledEvent {
pub order_id: u32,
}
impl Identifier for OrderEvent {
#[allow(dead_code)]
fn identifier(&self) -> String {
match self {
OrderEvent::Created(c) => c.order_id.to_string(),
OrderEvent::Updated(c) => c.order_id.to_string(),
OrderEvent::Cancelled(c) => c.order_id.to_string(),
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[allow(dead_code)]
pub struct ShipmentState {
pub shipment_id: u32,
pub order_id: u32,
pub customer_name: String,
pub items: Vec<String>,
}
#[derive(Debug, Clone, PartialEq)]
#[allow(dead_code)]
pub struct ShipmentViewState {
pub shipment_id: u32,
pub order_id: u32,
pub customer_name: String,
pub items: Vec<String>,
}
#[derive(Debug, PartialEq, Clone)]
#[allow(dead_code)]
pub enum ShipmentCommand {
Create(CreateShipmentCommand),
}
#[derive(Debug, PartialEq, Clone)]
pub struct CreateShipmentCommand {
pub shipment_id: u32,
pub order_id: u32,
pub customer_name: String,
pub items: Vec<String>,
}
impl Identifier for ShipmentCommand {
#[allow(dead_code)]
fn identifier(&self) -> String {
match self {
ShipmentCommand::Create(c) => c.shipment_id.to_string(),
}
}
}
#[derive(Debug, PartialEq, Clone)]
#[allow(dead_code)]
pub enum ShipmentEvent {
Created(ShipmentCreatedEvent),
}
#[derive(Debug, PartialEq, Clone)]
pub struct ShipmentCreatedEvent {
pub shipment_id: u32,
pub order_id: u32,
pub customer_name: String,
pub items: Vec<String>,
}
impl ShipmentEvent {
#[allow(dead_code)]
pub fn id(&self) -> u32 {
match self {
ShipmentEvent::Created(c) => c.shipment_id.to_owned(),
}
}
}