68 lines
1.3 KiB
Rust
68 lines
1.3 KiB
Rust
use chrono::prelude::*;
|
|
use common::ron_api::Difficulty;
|
|
use sqlx::{self, FromRow};
|
|
|
|
#[derive(Debug, Clone, FromRow)]
|
|
pub struct User {
|
|
pub id: i64,
|
|
pub name: String,
|
|
pub email: String,
|
|
pub lang: String,
|
|
}
|
|
|
|
#[derive(Debug, FromRow)]
|
|
pub struct UserLoginInfo {
|
|
pub last_login_datetime: DateTime<Utc>,
|
|
pub ip: String,
|
|
pub user_agent: String,
|
|
}
|
|
|
|
#[derive(Debug, FromRow)]
|
|
pub struct Recipe {
|
|
pub id: i64,
|
|
pub user_id: i64,
|
|
pub title: String,
|
|
pub lang: String,
|
|
pub estimated_time: Option<u32>, // [s].
|
|
pub description: String,
|
|
|
|
#[sqlx(try_from = "u32")]
|
|
pub difficulty: Difficulty,
|
|
|
|
pub servings: Option<u32>,
|
|
pub is_published: bool,
|
|
|
|
#[sqlx(skip)]
|
|
pub tags: Vec<String>,
|
|
|
|
#[sqlx(skip)]
|
|
pub groups: Vec<Group>,
|
|
}
|
|
|
|
#[derive(Debug, FromRow)]
|
|
pub struct Group {
|
|
pub id: i64,
|
|
pub name: String,
|
|
pub comment: String,
|
|
|
|
#[sqlx(skip)]
|
|
pub steps: Vec<Step>,
|
|
}
|
|
|
|
#[derive(Debug, FromRow)]
|
|
pub struct Step {
|
|
pub id: i64,
|
|
pub action: String,
|
|
|
|
#[sqlx(skip)]
|
|
pub ingredients: Vec<Ingredient>,
|
|
}
|
|
|
|
#[derive(Debug, FromRow)]
|
|
pub struct Ingredient {
|
|
pub id: i64,
|
|
pub name: String,
|
|
pub comment: String,
|
|
pub quantity_value: Option<f64>,
|
|
pub quantity_unit: String,
|
|
}
|