Split db::Connection implementation in submodules (db::user and db::recipe).
This commit is contained in:
parent
4248d11aa9
commit
fce4eade73
17 changed files with 1307 additions and 1234 deletions
|
|
@ -1,82 +0,0 @@
|
|||
use chrono::prelude::*;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct User {
|
||||
pub id: i64,
|
||||
pub name: String,
|
||||
pub email: String,
|
||||
}
|
||||
|
||||
pub struct UserLoginInfo {
|
||||
pub last_login_datetime: DateTime<Utc>,
|
||||
pub ip: String,
|
||||
pub user_agent: String,
|
||||
}
|
||||
|
||||
pub struct Recipe {
|
||||
pub id: i64,
|
||||
pub user_id: i64,
|
||||
pub title: String,
|
||||
pub description: String,
|
||||
pub estimate_time: Option<i32>, // [min].
|
||||
pub difficulty: Difficulty,
|
||||
|
||||
//ingredients: Vec<Ingredient>, // For four people.
|
||||
pub process: Vec<Group>,
|
||||
}
|
||||
|
||||
impl Recipe {
|
||||
pub fn empty(id: i64, user_id: i64) -> Recipe {
|
||||
Self::new(id, user_id, String::new(), String::new())
|
||||
}
|
||||
|
||||
pub fn new(id: i64, user_id: i64, title: String, description: String) -> Recipe {
|
||||
Recipe {
|
||||
id,
|
||||
user_id,
|
||||
title,
|
||||
description,
|
||||
estimate_time: None,
|
||||
difficulty: Difficulty::Unknown,
|
||||
process: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Ingredient {
|
||||
pub quantity: Option<Quantity>,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
pub struct Quantity {
|
||||
pub value: f32,
|
||||
pub unit: String,
|
||||
}
|
||||
|
||||
pub struct Group {
|
||||
pub name: Option<String>,
|
||||
pub input: Vec<StepInput>,
|
||||
pub output: Vec<IntermediateSubstance>,
|
||||
pub steps: Vec<Step>,
|
||||
}
|
||||
|
||||
pub struct Step {
|
||||
pub action: String,
|
||||
}
|
||||
|
||||
pub struct IntermediateSubstance {
|
||||
pub name: String,
|
||||
pub quantity: Option<Quantity>,
|
||||
}
|
||||
|
||||
pub enum StepInput {
|
||||
Ingredient(Ingredient),
|
||||
IntermediateSubstance(IntermediateSubstance),
|
||||
}
|
||||
|
||||
pub enum Difficulty {
|
||||
Unknown,
|
||||
Easy,
|
||||
Medium,
|
||||
Hard,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue