li7y/src/models.rs

44 lines
1,020 B
Rust
Raw Normal View History

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};
use time::OffsetDateTime;
2024-06-24 22:46:04 +02:00
use uuid::Uuid;
#[derive(Clone, Debug, Serialize, sqlx::FromRow)]
2024-06-24 22:46:04 +02:00
pub struct Item {
pub id: Uuid,
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,
#[serde(with = "time::serde::iso8601")]
pub created_at: OffsetDateTime,
2024-06-24 22:46:04 +02:00
}
#[derive(Debug, Deserialize)]
2024-06-24 22:46:04 +02:00
pub struct NewItem {
#[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,
}
#[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>,
#[serde(with = "time::serde::iso8601")]
pub created_at: OffsetDateTime,
2024-07-07 13:48:31 +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
}