From 1c09b0eb5db415985bfefb52786dbe48d757665e Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sat, 6 Sep 2025 18:31:40 +0200 Subject: feat: Provide basic barcode handling support --- crates/rocie-client/src/models/barcode.rs | 4 +-- crates/rocie-client/src/models/mod.rs | 4 +++ crates/rocie-client/src/models/unit.rs | 39 +++++++++++++++++++++++++++ crates/rocie-client/src/models/unit_amount.rs | 6 ++--- crates/rocie-client/src/models/unit_stub.rs | 36 +++++++++++++++++++++++++ 5 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 crates/rocie-client/src/models/unit.rs create mode 100644 crates/rocie-client/src/models/unit_stub.rs (limited to 'crates/rocie-client/src/models') diff --git a/crates/rocie-client/src/models/barcode.rs b/crates/rocie-client/src/models/barcode.rs index 7690be2..2b1759a 100644 --- a/crates/rocie-client/src/models/barcode.rs +++ b/crates/rocie-client/src/models/barcode.rs @@ -16,11 +16,11 @@ pub struct Barcode { #[serde(rename = "amount")] pub amount: Box, #[serde(rename = "id")] - pub id: i32, + pub id: i64, } impl Barcode { - pub fn new(amount: models::UnitAmount, id: i32) -> Barcode { + pub fn new(amount: models::UnitAmount, id: i64) -> Barcode { Barcode { amount: Box::new(amount), id, diff --git a/crates/rocie-client/src/models/mod.rs b/crates/rocie-client/src/models/mod.rs index 6c96c01..42fecc5 100644 --- a/crates/rocie-client/src/models/mod.rs +++ b/crates/rocie-client/src/models/mod.rs @@ -4,5 +4,9 @@ pub mod product; pub use self::product::Product; pub mod product_stub; pub use self::product_stub::ProductStub; +pub mod unit; +pub use self::unit::Unit; pub mod unit_amount; pub use self::unit_amount::UnitAmount; +pub mod unit_stub; +pub use self::unit_stub::UnitStub; diff --git a/crates/rocie-client/src/models/unit.rs b/crates/rocie-client/src/models/unit.rs new file mode 100644 index 0000000..95ec588 --- /dev/null +++ b/crates/rocie-client/src/models/unit.rs @@ -0,0 +1,39 @@ +/* + * rocie-server + * + * An enterprise grocery management system + * + * The version of the OpenAPI document: 0.1.0 + * Contact: benedikt.peetz@b-peetz.de + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Unit { + #[serde(rename = "description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub description: Option>, + #[serde(rename = "full_name_plural")] + pub full_name_plural: String, + #[serde(rename = "full_name_singular")] + pub full_name_singular: String, + #[serde(rename = "id")] + pub id: uuid::Uuid, + #[serde(rename = "short_name")] + pub short_name: String, +} + +impl Unit { + pub fn new(full_name_plural: String, full_name_singular: String, id: uuid::Uuid, short_name: String) -> Unit { + Unit { + description: None, + full_name_plural, + full_name_singular, + id, + short_name, + } + } +} + diff --git a/crates/rocie-client/src/models/unit_amount.rs b/crates/rocie-client/src/models/unit_amount.rs index 038adb0..3ab482c 100644 --- a/crates/rocie-client/src/models/unit_amount.rs +++ b/crates/rocie-client/src/models/unit_amount.rs @@ -14,13 +14,13 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UnitAmount { #[serde(rename = "unit")] - pub unit: String, + pub unit: uuid::Uuid, #[serde(rename = "value")] - pub value: i32, + pub value: i64, } impl UnitAmount { - pub fn new(unit: String, value: i32) -> UnitAmount { + pub fn new(unit: uuid::Uuid, value: i64) -> UnitAmount { UnitAmount { unit, value, diff --git a/crates/rocie-client/src/models/unit_stub.rs b/crates/rocie-client/src/models/unit_stub.rs new file mode 100644 index 0000000..03f81fd --- /dev/null +++ b/crates/rocie-client/src/models/unit_stub.rs @@ -0,0 +1,36 @@ +/* + * rocie-server + * + * An enterprise grocery management system + * + * The version of the OpenAPI document: 0.1.0 + * Contact: benedikt.peetz@b-peetz.de + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UnitStub { + #[serde(rename = "description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub description: Option>, + #[serde(rename = "full_name_plural")] + pub full_name_plural: String, + #[serde(rename = "full_name_singular")] + pub full_name_singular: String, + #[serde(rename = "short_name")] + pub short_name: String, +} + +impl UnitStub { + pub fn new(full_name_plural: String, full_name_singular: String, short_name: String) -> UnitStub { + UnitStub { + description: None, + full_name_plural, + full_name_singular, + short_name, + } + } +} + -- cgit 1.4.1