Service for editing/creating recipe

Other stuff...
This commit is contained in:
Greg Burri 2022-12-15 01:13:57 +01:00
parent adcf4a5a5d
commit cc2e5b6893
15 changed files with 323 additions and 146 deletions

View file

@ -1,22 +1,41 @@
use chrono::prelude::*;
pub struct User {
pub id: i64,
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: Option<String>,
pub description: String,
pub estimate_time: Option<i32>, // [min].
pub difficulty: Option<Difficulty>,
pub difficulty: Difficulty,
//ingredients: Vec<Ingredient>, // For four people.
pub process: Vec<Group>,
}
impl Recipe {
pub fn new(id: i64, title: String, description: Option<String>) -> 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: None,
difficulty: Difficulty::Unknown,
process: Vec::new(),
}
}
@ -34,13 +53,13 @@ pub struct Quantity {
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 input: Vec<StepInput>,
pub output: Vec<IntermediateSubstance>,
}
pub struct IntermediateSubstance {