first commit

This commit is contained in:
gustavooth
2026-07-26 21:12:38 -03:00
commit e6badb0d79
133 changed files with 38368 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use tokio_postgres::{Error, Row};
use uuid::Uuid;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Category {
pub id: Uuid,
pub display_name: String,
pub normalized_name: String,
pub description: String,
pub created_by: String,
pub active: bool,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NewCategory {
pub display_name: String,
pub normalized_name: String,
#[serde(default)]
pub description: String,
#[serde(default = "default_ai")]
pub created_by: String,
}
fn default_ai() -> String {
"ai".to_owned()
}
impl Category {
pub fn from_row(row: &Row) -> Result<Self, Error> {
Ok(Self {
id: row.try_get("id")?,
display_name: row.try_get("display_name")?,
normalized_name: row.try_get("normalized_name")?,
description: row.try_get("description")?,
created_by: row.try_get("created_by")?,
active: row.try_get("active")?,
created_at: row.try_get("created_at")?,
updated_at: row.try_get("updated_at")?,
})
}
}