2024-06-24 22:46:04 +02:00
|
|
|
// SPDX-FileCopyrightText: 2024 Simon Bruder <simon@sbruder.de>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
2024-07-11 21:50:03 +02:00
|
|
|
use time::OffsetDateTime;
|
2024-06-24 22:46:04 +02:00
|
|
|
use uuid::Uuid;
|
|
|
|
|
2024-07-11 17:25:01 +02:00
|
|
|
#[derive(Clone, Debug, Serialize, sqlx::FromRow)]
|
2024-06-24 22:46:04 +02:00
|
|
|
pub struct Item {
|
|
|
|
pub id: Uuid,
|
2024-07-10 01:14:49 +02:00
|
|
|
pub name: Option<String>,
|
2024-07-05 12:38:45 +02:00
|
|
|
pub parent: Option<Uuid>,
|
2024-07-07 13:48:31 +02:00
|
|
|
pub class: Uuid,
|
2024-07-11 21:50:03 +02:00
|
|
|
#[serde(with = "time::serde::iso8601")]
|
|
|
|
pub created_at: OffsetDateTime,
|
2024-06-24 22:46:04 +02:00
|
|
|
}
|
|
|
|
|
2024-07-11 17:25:01 +02:00
|
|
|
#[derive(Debug, Deserialize)]
|
2024-06-24 22:46:04 +02:00
|
|
|
pub struct NewItem {
|
2024-07-10 01:14:49 +02:00
|
|
|
#[serde(default)]
|
|
|
|
pub name: Option<String>,
|
2024-07-05 12:38:45 +02:00
|
|
|
#[serde(default)]
|
|
|
|
pub parent: Option<Uuid>,
|
2024-07-07 13:48:31 +02:00
|
|
|
pub class: Uuid,
|
|
|
|
}
|
|
|
|
|
2024-07-11 17:25:01 +02:00
|
|
|
#[derive(Clone, Debug, Serialize)]
|
2024-07-07 13:48:31 +02:00
|
|
|
pub struct ItemClass {
|
|
|
|
pub id: Uuid,
|
|
|
|
pub name: String,
|
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
|
|
pub parent: Option<Uuid>,
|
2024-07-11 21:50:03 +02:00
|
|
|
#[serde(with = "time::serde::iso8601")]
|
|
|
|
pub created_at: OffsetDateTime,
|
2024-07-07 13:48:31 +02:00
|
|
|
}
|
|
|
|
|
2024-07-11 17:25:01 +02:00
|
|
|
#[derive(Debug, Deserialize)]
|
2024-07-07 13:48:31 +02:00
|
|
|
pub struct NewItemClass {
|
|
|
|
pub name: String,
|
|
|
|
#[serde(default)]
|
|
|
|
pub parent: Option<Uuid>,
|
2024-06-24 22:46:04 +02:00
|
|
|
}
|